Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-18-2010, 04:47 AM   PM User | #1
vinumat
New to the CF scene

 
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
vinumat is an unknown quantity at this point
VBScript - not extracting data from database

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>
vinumat is offline   Reply With Quote
Old 03-18-2010, 07:23 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Add in a couple of lines:
Code:
Set RS = MyConn.Execute(query1)
If RS.EOF Then 
    Response.Write "No records returned from query: " & query1 & "<hr>"
End If
...
What happens?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Tags
database, getdata, vbscript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:10 AM.


Advertisement
Log in to turn off these ads.