If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > RS field value changes to null after If Not IsNull

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-03, 15:58
schwackmeister schwackmeister is offline
Registered User
 
Join Date: Mar 2003
Posts: 15
RS field value changes to null after If Not IsNull

I'm generating a report from a db, want a certain section of a table to be displayed only if there is data in a particular recordset field. The following code is intended to produce table rows only if a recordset field "Echo_Rpt_Comments" is not null. Execution of the code produced the "Comments:" headline, but the "Echo_Rpt_Comments" recordset data was not displayed.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Code:
<%
If Not IsNull(RcdsEcho("Echo_Rpt_Comments")) Then
%>

	<tr>
		<td width="10%">&nbsp;</td>
		<td width="20%">&nbsp;</td>
		<td width="70%">&nbsp;</td>
	</tr>
	
	<tr>
		<td bgcolor="Silver" colspan="2" width="30%">
			<font face="Arial"><b>Comments:</b></font>
		</td>
		<td width="70%">&nbsp;</td>
	</tr>
	
	<tr>
		<td width="10%">&nbsp;</td>
		<td colspan="2" width="90%">
			<font face="Arial"><%=RcdsEcho("Echo_Rpt_Comments")%></font>
		</td>
	</tr>
<%
End If
%>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

I tested by adding another "If Not IsNull" statement for the "Echo_Rpt_Comments" field immediately following the preceding code. The result indicated that the value of the recordset field had changed to null. Why?

My successful workaround is to use a variable to hold the contents of the recordset field, and use the variable instead of the recordset field. The following code works as expected.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Code:
<%
Dim Echo_Comments
Echo_Comments = RcdsEcho("Echo_Rpt_Comments")
If Not IsNull(Echo_Comments) Then
%>

	<tr>
		<td width="10%">&nbsp;</td>
		<td width="20%">&nbsp;</td>
		<td width="70%">&nbsp;</td>
	</tr>
	
	<tr>
		<td bgcolor="Silver" colspan="2" width="30%">
			<font face="Arial"><b>Comments:</b></font>
		</td>
		<td width="70%">&nbsp;</td>
	</tr>
	
	<tr>
		<td width="10%">&nbsp;</td>
		<td colspan="2" width="90%">
			<font face="Arial"><%=Echo_Comments%></font>
		</td>
	</tr>
<%
End If
%>
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This problem (and workaround solution) was observerd on 2 different web servers (TEST and PROD), each running WinNT4 (SP6a), IIS4. The db is Access97, web servers use ODBC driver (DSN) to hit it; MDAC v2.5 SP1 is installed on the boxes, as spec'd by the db vendor. Servers have both Jet v3.51 SP3 and Jet v4.0 SP6, but since I'm using ODBC to hit the db this is probably irrelevant.
Reply With Quote
  #2 (permalink)  
Old 05-14-03, 04:27
wakhy wakhy is offline
Registered User
 
Join Date: Jan 2003
Location: de/ro
Posts: 12
Recordset

Hi,

try to use one of the constants to define the type of cursor used:
Const adOpenDynamic = 2
Const adOpenStatic = 3

when opening the recordset, like this:

RSObj.Open strSqlQuery, strDataConn, adOpenStatic

The constants are defined in the adovbs.inc or just use the values.


The default value is adOpenForwardOnly, used when only one pass through a Recordset is needed.

adOpenDynamic - Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them.

adOpenStatic - Uses a static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.

adOpenForwardOnly - Default. Uses a forward-only cursor. Identical to a static cursor, except that you can only scroll forward through records. This improves performance when you need to make only one pass through a Recordset.
Reply With Quote
  #3 (permalink)  
Old 05-15-03, 18:32
schwackmeister schwackmeister is offline
Registered User
 
Join Date: Mar 2003
Posts: 15
thank you - <DUH!>...

I think I've been bitten by that bug before... or one like it, anyway. I knew immediately you were right - testing just confirmed it.

thanks again for the reminder!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On