Groups | Blog | Home
all groups > inetserver asp db > august 2007 >

inetserver asp db : Problem with retrieving values in a combo box from a query



Jack
8/21/2007 11:12:01 AM
Hi,
I am trying to retrieve values from a query in a list box. However, it is
giving me no recordset. Although I get recordset when I query this access
database. Any help for resolution on this is appreciated. Thanks

CODE:
<%
Dim oConn
Dim oRS
Dim vCS
Dim sqltxt

set oConn=server.CreateObject("ADODB.connection")
vCS = "Provider=Microsoft.Jet.OLEDB.3.51"
vCS = vCS & "; Data Source=C:\Sailors.mdb"
oConn.connectionstring = vCS
oConn.Open

set oRS = server.CreateObject("ADODB.recordset")
sqltxt = "SELECT BoatName, BoatClass FROM Boats;"
oRS.Open sqltxt,oConn
%>
<select name="lstBoats" size="1">
<%
Do while not oRS.EOF
response.Write "<option value='" & oRS("BoatName") & "'>"
response.Write oRS("BoatClass") & "</option>"
oRS.MoveNext
Loop

%>
</select>
<%oRS.Close
Bob Barrows [MVP]
8/21/2007 2:31:28 PM
[quoted text, click to view]

Why 3.51? You're not using a database that's that old are you? Use the
4.0 provider.

[quoted text, click to view]

I see no major problems here. Do you have an On Error Resume Next
statement anywhere that is masking your errors?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jack
8/21/2007 2:48:00 PM
Hi Bob,
I do not have any on error resume next statement. What should be my next
step to get the recordset? I have changed to 4.0. Thanks


[quoted text, click to view]
Jack
8/21/2007 3:14:01 PM
Thanks Bob for further advise. I changed the Provider to 4.0. I also checked
that the database had no IUSR_USERMACHINE connection. Doing so is giving me
result. However, I am getting only the second field instead of the two fields
described in the queries. Any idea why the first field will not be displayed?
Thanks again.

[quoted text, click to view]
Bob Barrows [MVP]
8/21/2007 5:55:12 PM
Again, I see no obvious problem. If it was a problem with your query,
you would be getting an error message.

Are you sure you are connecting to the correct database?

As an aside, it is my preference to test for EOF immediately after
opening the recordset so I can return a "no records" message to the
client.

[quoted text, click to view]


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Bob Barrows [MVP]
8/21/2007 6:31:40 PM
[quoted text, click to view]

I don't understand what you mean by that sentence. "... checked that the
database had no IUSR_USERMACHINE connection"??

[quoted text, click to view]

Doing what?

[quoted text, click to view]

There is more than one query?

[quoted text, click to view]

Sorry, but no.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

AddThis Social Bookmark Button