954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

html with vbscript and database

when I try running this asp using iexplorer, it does not return anything other than 'Country..... City..... Currency..... Population' as heading. How come it's not connecting and getting the data from the database?? Please help!
Thanks

<% @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
<ul>
  <%
     WHILE NOT RS.EOF
  %>

     <li>
       <% =RS("Country") %> .....
       <% =RS("City") %> .....
       <% =RS("Currency") %> .....
       <% =RS("Population") %>
     </li>
  <%
       RS.MoveNext 
     WEND 
  %>
</ul>
</body>
</head>
vinumat
Newbie Poster
2 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

Try replacing "MydbFilePath" with the actual hardcoded path of the access DB.

If you do response.write MyConn.State straight after your MyConn.Open, this should output a '1' or 'true' so you know you have an open connection

Within your tags, try referencing your recordset fields like this: -

<%=rs.Fields("Country")%>


If you run the same query in Access, do you get results?

Hope this helps

WebspoonUK
Newbie Poster
22 posts since Mar 2010
Reputation Points: 10
Solved Threads: 2
 

Thanks a lot WebspoonUK ..That did really help me solve the problem. Thanks a million :)

vinumat
Newbie Poster
2 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

No worries - happy to help. Could you mark the thread as solved by me? Cheers

WebspoonUK
Newbie Poster
22 posts since Mar 2010
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You