Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Posts
    11

    Unanswered: connection problem

    Can anyone please help me by pointing out why this is not working and gives a configuration error.

    Code:
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.Provider="Microsoft.Jet.OLEDB.4.0"
    conn.Open(Server.Mappath("C:\Inetpub\vhosts\weekdayweddings.net\httpdocs\wdw\weddingphotographers.mdb"))
    
    set rs = Server.CreateObject("ADODB.recordset")
    rs.Open "SELECT Photographer, Postcode FROM details", conn
    %>
    I know the database is OK and can be connected to because I use it with another code returning results from a form with user input. All this is in the same root folder. The successful code looks like this.
    Code:
    <%
    u_search=request.form("u_search")
    u_where=request.form("u_where")
    if u_search = "" or u_where= "" then 
    response.redirect "searchinput.asp"
    
    end if
    accessdb="weddingphotographers" 
    cn="DRIVER={Microsoft Access Driver (*.mdb)};"
    cn=cn & "DBQ=" & server.mappath(accessdb)
    Set rs = Server.CreateObject("ADODB.Recordset")
    
    sql = "select * from fullpups where " & u_where &" like '%%"& u_search & "%%'" 
    
    rs.Open sql, cn
    If  rs.eof then
       search="nothing"
    end if
    %>
    But it is of course a different kind usage. In the former I am trying to establish a connection simply to call a function that populates a table with single pieces of data. e.g. x when y=3.

    I know I am slow on understanding but any help would be appreciated.

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Well you are using different Provider details for starters that may be causing problems.

    The other problem may be around your use of Server.MapPath. You use the MapPath method to get the physical location for a given folder/file so saying

    Server.MapPath("weddingphotos.mdb") would result in something like "C:\Projects\WeddingStuff\Photos\WeddingPhotos.mdb "

    Trying to map with a full path specified would fail due to the path/file supplied not being found in the executing path,...

    I think.... haven't played with it for a while so I could be wrong

Posting Permissions

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