PDA

View Full Version : VBScript - not extracting data from database


vinumat
03-18-2010, 04:47 AM
Hi again,

I tried the below code and have a valid 'countrydb.mdb' database. But after running this, all it returns is 'Country..... City..... Currency..... Population' and nothing else. It should be displaying the country name, city etc.

Can you tell me why??? Pleasee...

Thanks a lot guys!


<% @language = VBScript %>
<head>
<TITLE>ASP - Country Query</TITLE>
<body>
<%
Dim MyConn, MydbFilePath
Set MyConn = Server.CreateObject("ADODB.Connection")
MydbFilePath = Server.MapPath("countrydb.mdb")

MyConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & MydbFilePath & ";"
query1 = "SELECT * FROM Countrytbl"
Set RS = MyConn.Execute(query1)
%>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


Country..... City..... Currency..... Population<br><br>
<ul>
<%
WHILE NOT RS.EOF
%>

<li>
<% =RS("Country") %> .....
<% =RS("City") %> .....
<% =RS("Currency") %> .....
<% =RS("Population") %>
</li>
<%
RS.MoveNext
WEND
%>
</ul>
</body>
</head>

Old Pedant
03-18-2010, 07:23 AM
Add in a couple of lines:

Set RS = MyConn.Execute(query1)
If RS.EOF Then
Response.Write "No records returned from query: " & query1 & "<hr>"
End If
...

What happens?