Forums

ASP

This topic is locked

memo field does not display when using "if then"

Posted 08 Oct 2003 01:52:27
1
has voted
08 Oct 2003 01:52:27 chris holloway posted:
A wierd error. When I use any if/then statement on or before a memo field. It will not display the field on the page. If I change the type to text in the Access database it works fine. It's not an error in the statement, infact I can put it outside the <% end if %> and it still wont display.

Any ideas ?

Replies

Replied 03 Nov 2005 12:21:50
03 Nov 2005 12:21:50 Ole Wegard Utne replied:
Hi everyone
Dispite this is an old posting I encountered this problem recently.
Is there a solution for this? I use plain ASP and TEXT field in mySQL.
I have even changed from just selecting * in the SQL to selecting all fields with the TEXT field at ultimate position, but no go??!

Quite urgent anyone..........

Thanks in advance

Edited by - owu on 03 Nov 2005 12:23:34
Replied 11 Nov 2005 18:55:19
11 Nov 2005 18:55:19 myke black replied:
please post your code here so we can help you,

thanks

myke black
Replied 25 Jan 2008 04:59:09
25 Jan 2008 04:59:09 Andrew Workman replied:
Wow, I'm really suprised nobody has posted back to this since 2005.

I just recently ran into this error. When I had any kind of IF THEN statement on my page (even if it did not relate to the memo field being written to the page) the memo field would throw the following error:

Microsoft VBScript runtime error '800a005e'
Invalid use of Null: 'Replace'
/company/execoverview.asp, line 81

Strangely, I only received the error when there was actually data in the memo field. When the field was empty the page would simply display nothing, without the error.

After searching for what seemed like forever without an answer, I finally ran across a document from WebAssisst regarding a Cursor Location error in Dreamweaver 8.02 (not at all where I expected the problem to actually be). The document begins as follows:
--------------------------------
In Dreamweaver 8.02, when a dynamic page generated with the ASP JavaScript server model attempts to update an Access memo field or Microsoft SQL server nText field, "null" is displayed instead of the memo field value. While the issue applies to DataAssist, the described fix could be applied to any affected dynamic page. The issues stems from the changed Recordset server behavior in Dreamweaver 8.02 which does not properly alter the cursor location property.
--------------------------------

At first I thought "darn, this only applies to ASP JavaScript and I'm using ASP VBScript, but I decided to try the fix anyway: Here's the fix they posted (with slight changes to the code to make it VBScript compatible instead of JavaScript):

The Issue
----------------------------
The Dreamweaver 8.02 release of Dreamweaver updated the server-side code generated by Dreamweaver to protect databases against SQL Injection. Unfortunately, Dreamweaver 8.02 no longer allows the database property called CursorLocation to be set from the Property inspector. The CursorLocation property determines where the recordset should be stored, on the server (the default, represented by the number 2) or on the client (3). The default is to store the recordset on the server and this is most often the proper choice. However, in circumstances where either Access memo fields or SQL Server nText fields are used, the recordset must be stored on the client or these fields will display a Null value instead of the expected memo field value.

The Solution
----------------------------
To correct the problem, you'll need to add a single line of code that explicitly sets the CursorLocation property to your recordset code. Here are the necessary steps:

1. From the Server Behaviors panel, select your recordset server behavior.
2. Switch to Code view to display the selected recordset code.
3. Locate the code line which opens the recordset. If your recordset is named rsExample, the code will look like this:

<pre id=code><font face=courier size=2 id=code> var rsExample = rsExample_cmd.Execute() </font id=code></pre id=code>

4. Place your cursor in front of the located code line and press Enter (Windows) or Return (Mac).
It's important to maintain a blank line between the two code blocks.
5. Insert the following code:

<pre id=code><font face=courier size=2 id=code> rsExample_cmd.ActiveConnection.CursorLocation = 3 </font id=code></pre id=code>


Here is my original code which gave the error...
<pre id=code><font face=courier size=2 id=code>
&lt;%
Dim ExecOverview
Dim ExecOverview_cmd
Dim ExecOverview_numRows

Set ExecOverview_cmd = Server.CreateObject ("ADODB.Command"
ExecOverview_cmd.ActiveConnection = MM_rbdata_STRING
ExecOverview_cmd.CommandText = "SELECT * FROM Contacts ORDER BY RecordSort ASC"
ExecOverview_cmd.Prepared = true

Set ExecOverview = ExecOverview_cmd.Execute
ExecOverview_numRows = 0
%&gt;
</font id=code></pre id=code>

AND the Fixed code with the above suggestion:
<pre id=code><font face=courier size=2 id=code>
&lt;%
Dim ExecOverview
Dim ExecOverview_cmd
Dim ExecOverview_numRows

Set ExecOverview_cmd = Server.CreateObject ("ADODB.Command"
ExecOverview_cmd.ActiveConnection = MM_rbdata_STRING
ExecOverview_cmd.CommandText = "SELECT * FROM Contacts ORDER BY RecordSort ASC"
ExecOverview_cmd.Prepared = true

ExecOverview_cmd.ActiveConnection.CursorLocation = 3 <font color=red>&lt;&lt; HERE IS THE FIXED LINE</font id=red>
Set ExecOverview = ExecOverview_cmd.Execute
ExecOverview_numRows = 0
%&gt;
</font id=code></pre id=code>
Here is the link to the original document: www.webassist.com/media/professional/support/TechNotes/10009.pdf

I do not understand enought about this to tell you WHY this specifically worked for me, but IT DID! It worked beautifully, and easily. Hope this helps anyone out there to avoid all the searching I went through.

Edited by - failbucket on 25 Jan 2008 05:02:07

Reply to this topic