Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vairable Declarations problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi,

Ive got the following code in (A) below which Ive copied from a textbook which works but when I move the vairable declaration 'Dim rsItem' from in-line to the top as in (B) it doesnt work. Why ?

(A)
<%
Dim blnNew
' detect whether the user is adding a new item or editing an existing one
Select Case Request.QueryString(&quot;Action&quot;)
Case &quot;AddNew&quot;
blnNew = True
Case &quot;Edit&quot;
blnNew = False
End Select

If blnNew Then
Response.Write _
&quot;<CENTER><H1>Wrox Classifieds<BR>Add New Sale Item</H1></CENTER>&quot; & _
&quot;<P>Please add the following information for the item you have for sale. &quot;
Else
Response.Write _
&quot;<CENTER><H1>Wrox Classifieds<BR>Edit Sale Item</H1></CENTER>&quot; & _
&quot;<P>Please edit the information for this item currently for sale. &quot;
Dim rsItem
Set rsItem = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strSQL = &quot;SELECT * FROM Item WHERE ItemID = &quot; & Request(&quot;Item&quot;) & &quot;;&quot;
rsItem.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText
End If

%>



(B)
<%
Dim blnNew
Dim rsItem
' detect whether the user is adding a new item or editing an existing one
Select Case Request.QueryString(&quot;Action&quot;)
Case &quot;AddNew&quot;
blnNew = True
Case &quot;Edit&quot;
blnNew = False
End Select

If blnNew Then
Response.Write _
&quot;<CENTER><H1>Wrox Classifieds<BR>Add New Sale Item</H1></CENTER>&quot; & _
&quot;<P>Please add the following information for the item you have for sale. &quot;
Else
Response.Write _
&quot;<CENTER><H1>Wrox Classifieds<BR>Edit Sale Item</H1></CENTER>&quot; & _
&quot;<P>Please edit the information for this item currently for sale. &quot;

Set rsItem = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strSQL = &quot;SELECT * FROM Item WHERE ItemID = &quot; & Request(&quot;Item&quot;) & &quot;;&quot;
rsItem.Open strSQL, objConn, adOpenForwardOnly, adLockOptimistic, adCmdText
End If
%>


 
It should work, but because you gave only a part of the code so I don't know what the problem is (I cannot test it).
Could you give more information like: error message?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top