I am trying to connect to MS Access 2003 database with classic ASP. Here is a sample of my asp code: <% Dim adoCon Dim rs Dim strSQL Set adoCon = Server.CreateObject("ADODB.Connection") adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT record.link, record.date FROM record;" rs.Open strSQL, adoCon Do While not rs.EOF %> <table width="100%" border-"1"> <tr><td> <% Response.Write (rs("Link")) %> </td></tr> <tr> <td> <% Response.Write (rs("Date")) %> </td> </tr> <% rs.MoveNext Loop %> </table> <% rs.Close Set rs = Nothing Set adoCon = Nothing %> Code (markup): db1.mdb is in the root folder on my server. I do not see anything on the page..its blank. plz help.
Well, as all you are doing here is reading from the .mdb, it shouldn't be a permissions issue. Is the script in the webroot as well? It's a bummer that you are getting a blank page instead of an error. If you want to PM me your email address, I'll send you a custom error handling script that will detail everything you could know about ASP errors. Make sure there's no "On Error Resume Next" above this script, as that would give you a blank page if there were an error. I do see one thing that you'll want to change here, even though it wouldn't be causing a scripting error: rs.Open strSQL, adoCon Do While not rs.EOF %> <table width="100%" border-"1"> <tr><td> <% Response.Write (rs("Link")) %> </td></tr> <tr> <td> <% Response.Write (rs("Date")) %> </td> </tr> <% rs.MoveNext Loop %> </table> Code (markup): should be: rs.Open strSQL, adoCon %> <table width="100%" border="1"> <% Do While not rs.EOF %> <tr><td> <% Response.Write (rs("Link")) %> </td></tr> <tr> <td> <% Response.Write (rs("Date")) %> </td> </tr> <% rs.MoveNext Loop %> </table> Code (markup): That is, start your table before the loop. Or maybe better yet: <% Dim adoCon Dim rs Dim strSQL Dim strOut Set adoCon = Server.CreateObject("ADODB.Connection") adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db1.mdb") Set rs = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT record.link, record.date FROM record;" rs.Open strSQL, adoCon strOut = "<table width=""100%"" border=""1"">" Do While not rs.EOF strOut = strOut & "<tr><td>" & rs("Link") & "</td></tr>" & _ "<tr><td>" & rs("Date") & "</td></tr>" rs.MoveNext Loop strOut = strOut & "</table>" rs.Close Set rs = Nothing Set adoCon = Nothing Response.Write strOut %> Code (markup):
check your Server.MapPath with this code response.write Server.MapPath you will know exactly the folder
You say "I do not see anything on the page..its blank" Go and view the page source. most likely you will find an error displayed
no error in source code..but i guess its because the website is hosted on linux. I am going to change it to windows.
Just looking at your code I would suggest that you don't place the database in the wwwroot folder. You may want to create a folder called like db at the same level as the root. Then in your code do something like Server.MapPath("..\db1.mdb") If you place it in the wwwroot others will be able to download it. Just a thought for you to consider.