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!

Type Mismatch Error when Selecting from Database

Status
Not open for further replies.

TheShadow2000

Programmer
Dec 20, 2001
4
I have an ASP page in which I connect to a database twice. The first time, the page retrieves a Category ID based on input from the previous page. After that, the page is to search a different table and retrieve all entries that have the above mentioned Category ID number. Howevever, when I try to perform a loop, I get a Type Mismatch Error. My code is below. Note that the variable catnum was defined before this code.

Set objConn2 = Server.CreateObject("ADODB.Connection")
strConnection2 ="DSN=ASPDB;Database=ASPDB;"
objConn2.open strConnection2
strQuery2 = "Select Name, URL FROM Favorites WHERE Category_ID = "
strQuery2 = strQuery2 & catnum

Set objRS2 = objConn2.Execute(strQuery2)
While Not objRS2.EOF
Response.write &quot;<a href=&quot; & &quot;'&quot; & objRS(&quot;URL&quot;) & &quot;'&quot; & &quot;>&quot;
Response.write objRS(&quot;Name&quot;) & &quot;</a>&quot; & &quot;<br>&quot;
objRS2.MoveNext
Wend

objRS2.close
objConn2.close
Set objRS2=nothing
Set objConn2=nothing

The error occurs on the line &quot;While Not objRS2.EOF&quot;

Any and all help is greatly appreciated. Hopefully its only a dumb error on my part.

Thanks.
 
Do you not need a recordset object?
Dim objRS
Set objRS = Server.createObject(&quot;ADODB.Recordset&quot;)
 
All variables shown have been defined before this code is executed. I have simply used &quot;Dim objRS&quot; in the past without problems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top