Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / August 2007



Tip: Looking for answers? Try searching our database.

Problem with retrieving values in a combo box from a query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 21 Aug 2007 19:12 GMT
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
Set oRS = nothing %>
Bob Barrows [MVP] - 21 Aug 2007 19:31 GMT
> Hi,
> I am trying to retrieve values from a query in a list box. However,
[quoted text clipped - 11 lines]
> set oConn=server.CreateObject("ADODB.connection")
> vCS = "Provider=Microsoft.Jet.OLEDB.3.51"

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

> vCS = vCS & "; Data Source=C:\Sailors.mdb"
> oConn.connectionstring = vCS
[quoted text clipped - 3 lines]
> sqltxt = "SELECT BoatName, BoatClass FROM Boats;"
> oRS.Open sqltxt,oConn

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

Signature

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 - 21 Aug 2007 22:48 GMT
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

> > Hi,
> > I am trying to retrieve values from a query in a list box. However,
[quoted text clipped - 25 lines]
> I see no major problems here. Do you have an On Error Resume Next
> statement anywhere that is masking your errors?
Bob Barrows [MVP] - 21 Aug 2007 22:55 GMT
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.

> Hi Bob,
> I do not have any on error resume next statement. What should be my
[quoted text clipped - 5 lines]
>>> this access database. Any help for resolution on this is
>>> appreciated. Thanks

Signature

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 - 21 Aug 2007 23:14 GMT
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.

> Again, I see no obvious problem. If it was a problem with your query,
> you would be getting an error message.
[quoted text clipped - 14 lines]
> >>> this access database. Any help for resolution on this is
> >>> appreciated. Thanks
Bob Barrows [MVP] - 21 Aug 2007 23:31 GMT
> Thanks Bob for further advise. I changed the Provider to 4.0. I also
> checked that the database had no IUSR_USERMACHINE connection.

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

> Doing so is giving me result.

Doing what?

> However, I am getting only the second field
> instead of the two fields described in the queries.

There is more than one query?

> Any idea why the
> first field will not be displayed? Thanks again.

Sorry, but no.
Signature

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.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.