Page 1 of 2 12 LastLast
Results 1 to 25 of 30
  1. #1
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    ASP - problem with database connectivity
    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
    %>

    db1.mdb is in the root folder on my server.

    I do not see anything on the page..its blank. plz help.

  2. #2
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    Try This:

    <%
    Set Conn = Server.CreateObject("ADODB.Connection")

    Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    Conn.ConnectionString = "Data Source=" & Server.MapPath ("db1.mdb")
    Conn.Open

    Set rs = Server.CreateObject("ADODB.Recordset")

    Rs.Open "SELECT * from record", Conn, 1,3

    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
    Conn.Close
    Set Conn = Nothing
    %>


    In the line

    Rs.Open "SELECT * from record", Conn, 1,3

    is record a table in Access??

  3. #3
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    ok..will try. yes record is a table in Access.

    don't I have to declare variables first with Dim?
    Also can you tell me what is Conn, 1,3 in the line Rs.Open "SELECT * from record", Conn, 1,3

    thnx

  4. #4
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    Quote Originally Posted by akinak
    ok..will try. yes record is a table in Access.

    don't I have to declare variables first with Dim?
    >> Yes go ahead a declare them, however not required but is a good idea

    Also can you tell me what is Conn, 1,3 in the line Rs.Open "SELECT * from record", Conn, 1,3
    >> I would have to look that one up but I always use it

    thnx
    ........

  5. #5
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    okay..will try and let you know tomorrow..thnx for the help.

  6. #6
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    okay..I tried but its still not working...I am getting a blank page again. I don't knw where I am going wrong...plz help

  7. #7
    ABW Ambassador Boom or Bust's Avatar
    Join Date
    February 3rd, 2008
    Posts
    3,955
    Since you're getting a blank page rather than an error, you should check your select statement and data to make sure it's not returning an empty set. Perhaps broaden your select statement to see if any records are returned and narrow it down from there. That way you know the rest of the routine is working. Insert a <%Response.Write "Looped"%> inside the loop to see if it's actually looping...



    X

  8. #8
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    okay..will try that.
    One more thing..,in IE I get a blank page..but in firefox, I see all the code on the page..

  9. #9
    ABW Ambassador Boom or Bust's Avatar
    Join Date
    February 3rd, 2008
    Posts
    3,955
    Quote Originally Posted by akinak
    okay..will try that.
    One more thing..,in IE I get a blank page..but in firefox, I see all the code on the page..
    Are you running your own server? The fact that you see the source when loading an ASP page means the server isn't parsing ASP...



    X

  10. #10
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    As Ed stated it sounds link a problem with IIS service on you workstation/server. What are you running your code on? local XP or Vista Box? Local Server running Windows Server 2000 or 2003? Or are you running on your host Server?

  11. #11
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    No..I have my website hosted on a linux server through a hosting company..could linux server be the problem?

  12. #12
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    Quote Originally Posted by kse
    As Ed stated it sounds link a problem with IIS service on you workstation/server. What are you running your code on? local XP or Vista Box? Local Server running Windows Server 2000 or 2003? Or are you running on your host Server?
    running it on host server

  13. #13
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    ASP will not run on a regular linux server. Some host try to run ASP on linux using cilisoft etc. Does your host say you can run ASP?? I suggest if you want to run ASP get a hosting package that run Windows Server.

  14. #14
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    oh.. I'll contact my host then. is there no other solution?

  15. #15
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    Quote Originally Posted by akinak
    oh.. I'll contact my host then. is there no other solution?
    I have tried linux/ASP/Access but never found one that I would use.

    What Host and package are you using? I will see if they have anything that you may try.

  16. #16
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    my host says that it won't run ASP..

    will have to get it on windows server now...
    I apologize for wasting your time..but really appreciate your help..thnx.

  17. #17
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    No problem at all.

    Good Luck

  18. #18
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    thnx

  19. #19
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    I am back with a new problem. I can access my database now. But, when I get hyperlinks on the webpage, they are coming with # sign before and after the link..like..
    #www.site.com#

    I am getting links from a "hyperlink" field in Ms Access. How can I resolve this.

  20. #20
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    Not sure I understand the problem, are you able to post the code that reads and displays the url from your database? I am also assuming that you are using ASP on Windows Hosting?

  21. #21
    ABW Ambassador PatrickAllmond's Avatar
    Join Date
    September 20th, 2005
    Location
    OKC
    Posts
    1,219
    Akinak,

    Please tell me you have plans to move to asp.net eventually. Classic ASP (3.0) is antiquated.
    ---
    This response was masterly crafted via the fingers of Patrick Allmond who believe you should StopDoingNothing starting today.
    ---
    Focus Consulting is where I roll | Follow @patrickallmond on Twitter
    Search Engine Marketing | Search Engine Optimization | Social Media | Online Video

  22. #22
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    Quote Originally Posted by kse
    Not sure I understand the problem, are you able to post the code that reads and displays the url from your database? I am also assuming that you are using ASP on Windows Hosting?
    Yes I am on Windows hosting now. Here isthe code I have:

    Code:
    <%
    Dim Conn
    Dim rs
    Set Conn = Server.CreateObject("ADODB.Connection")
    
    Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
    Conn.ConnectionString = "Data Source=" & Server.MapPath ("db1.mdb")
    Conn.Open
    
    Set rs = Server.CreateObject("ADODB.Recordset") %>
    <%
    Rs.Open "SELECT * from record", Conn, 1,3
    
    Do While not rs.EOF %>
    <table width="100%" border="1">
    <tr><td><a href= "<%=(ltrim(rs.Fields.Item("link").Value))%>"><%=(ltrim(rs.Fields.Item("link").Value))%></a></td></tr>
    <tr> <td>  <% Response.Write rs("Date") %> </td>
    </tr>
    <%
    rs.MoveNext 
    Loop
    %>
    </table>
    <%
    rs.Close
    Set rs = Nothing
    Conn.Close
    Set Conn = Nothing
    %>

  23. #23
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    Not sure why you have:

    <a href= "<%=(ltrim(rs.Fields.Item("link").Value))%>"><%=(ltrim(rs.Fields.Item("link").Value))%></a>

    Is it just the url stored in the link feild in your database???

    The following code should work:

    <a href= "<%=rs("link")%>"><%=rs("link")%></a>

  24. #24
    Newbie
    Join Date
    October 15th, 2008
    Location
    San Diego
    Posts
    46
    kse...the one you gave does work, but I am still having the same problem. I don't see any sign or even space in my database. I hope this is not an issue with MS Access 2003. What can I do?

  25. #25
    ABW Ambassador kse's Avatar
    Join Date
    November 29th, 2005
    Posts
    2,511
    Akinak I do not know what to suggest can access 2003 save in 2000 format, if so give that a try. Also just print out your values you are reading from the access table and see if the # sign is their when you print the value.

    I do a lot of printing to screen when I have such a problem to find exactly where the problem starts.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Added Date to MySQL Database using asp
    By kse in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: October 26th, 2009, 06:31 PM
  2. Web Developer ASP / ASP.NET and PHP.
    By Murray Newlands in forum Job Postings
    Replies: 0
    Last Post: July 24th, 2007, 05:23 AM
  3. Poll: ASP, ASP.NET or PHP
    By PatrickAllmond in forum Programming / Datafeeds / Tools
    Replies: 9
    Last Post: October 5th, 2005, 09:38 AM
  4. Prices hardcoded into database links... see problem
    By mcdavidmeek in forum ShareASale - SAS
    Replies: 5
    Last Post: March 27th, 2004, 11:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •