View Complete Thread
  • Cannot Access DB when web application is moved to new server

    May 30, 2010 12:02 PM|MannyL|LINK

    I want to move a web application I developed to one of my new servers (I host).  The web application uses an Access DB.  I use a CRUD application to Add/Modfiy/Delete records in the Access DB which works just fine on the current live site.  However, after I move the web application to one of my other servers (one is Windows Server 2008 and the other is Windows Server 2003) the CRUD application can no longer access the DB.  I get the error listed below.  The permissions on both the DB folder within the web app as well as permissions on the .mdb file are the same as the current live application where all of this functions just fine.  The current live application is running on another of my Windows 2003 Servers.

    ATAF 6.1.0 debug program
    Server information

    Server name http://danellispreads.com
    Server software Microsoft-IIS/7.0
    Meta base path /category/debug.asp
    Path info C:\dino\
    Testing database connection
     adodb.connection is OK
     
    Could not open database object with connection string
    Error Number= #-2147467259
    Error Desc.= [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
     
    Testing your table
     Could not open database BusinessCategory_tbl
    Error Number= #3704
    Error Desc.= Operation is not allowed when the object is closed.
    Could NOT modify data in your table BusinessCategory_tbl, there must be R/W/C rights in the directory where the database is located
    Error Number= #3704
    Error Desc.= Operation is not allowed when the object is closed. 

    Here is the .asp code used for the DEBUG page:

    <%
    On Error Resume Next
    QU = Chr(34)
    Qs = Chr(39)
    DSN =  "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath ("../fpdb/member.mdb")
    Table = "BusinessCategory_tbl"
    imagedir = "images/"
    %>
    <html>
    <head>
    <meta http-equiv="+Content-Type" content="text/html"charset="windows-1252">
    <title>ATAF 6.1.0 Debug page</title>
    </head>
    <body style="font-family: Tahoma; font-size: 8pt">
    <table style="font-family: Tahoma; font-size: 8pt">
    <tr><td colspan="2"><b><font size="5">ATAF 6.1.0 debug program</font></b></td></tr>
    <tr><td colspan="2"><b><font size="4">Server information</font></b></td></tr>
    <tr><td nowrap>Server name</td><td>http://<%=Request.ServerVariables("SERVER_NAME")%></td></tr>
    <tr><td nowrap>Server software</td><td><%=Request.ServerVariables("SERVER_SOFTWARE")%></td></tr>
    <tr><td nowrap>Meta base path</td><td><%=Request.ServerVariables("PATH_INFO")%></td></tr>
    <tr><td nowrap>Path info</td><td><%=Request.ServerVariables("APPL_PHYSICAL_PATH")%></td></tr>
    <tr><td colspan="2"><font size="4"><b>Testing database connection</b></font></td></tr>
    <tr><td></td><td>
    <%
    Err.Clear
    Set conntemp = server.CreateObject("adodb.Connection")
    If Err <> 0 Then
       Response.write "<font color="+qu+"#FF0000"+qu+" > "
       Response.Write "Could not create adodb object<br>"
       Response.Write "Error Number= #<b>" & Err.Number & "</b><br>"
       Response.Write "Error Desc.= <b>" & Err.Description & "</b><br>"
       Response.write "</font>"
    Else
        Response.Write "adodb.connection is OK<br>"
    End If
    %>
    </td></tr>
    <tr><td></td><td>
    <%
    Err.Clear
    conntemp.Open DSN
    If Err <> 0 Then
       Response.write "<font color="+qu+"#FF0000"+qu+">"
       Response.Write "Could not open database object with connection string " + DSN + "<br>"
       Response.Write "Error Number= #<b>" & Err.Number & "</b><br>"
       Response.Write "Error Desc.= <b>" & Err.Description & "</b><br>"
       Response.write "</font>"
    Else
        Response.Write "DSN connection is OK<br>"
        Response.Write "ADODB provider : " + conntemp.Provider + "<br>"
        Response.Write "ADODB connectionstring : " + conntemp.ConnectionString + "<br>"
    End If
    %>
    </td></tr>
    <tr><td colspan="2"><font size="4"><b>Testing your table</b></font></td></tr>
    <tr><td></td><td>
    <%
    Err.Clear
    Sqlstr = "SELECT * From " + Table
    Set rs = conntemp.Execute(Sqlstr)
    If Err <> 0 Then
       Response.write "<font color="+qu+"#FF0000"+qu+">"
       Response.Write "Could not open database " + Table + "<br>"
       Response.Write "Error Number= #<b>" & Err.Number & "</b><br>"
       Response.Write "Error Desc.= <b>" & Err.Description & "</b><br>"
       Response.write "</font>"
    Else
        Response.Write "Table " + Table + " exist and is OK<br>"
        Response.Write "Table definition"
        Response.Write "<Table style = "+qu+"font-family: Tahoma; font-size: 8pt"+qu+">"
        Response.Write "<tr><td>name</td><td>Type</td><td>Actual size</td><td>Value</td><td>Nummericscale</td>"
        For i = 0 To rs.Fields.Count - 1
         Response.Write "<tr>"
         Response.Write "<td>" + rs(i).Name + "</td>"
         Response.Write "<td>"
         Response.Write rs(i).Type
         Response.Write "</td>"
         Response.Write "<td>"
         Response.Write rs(i).ActualSize
         Response.Write "</td>"
         Response.Write "<td>"
         Response.Write rs(i).Value
         Response.Write "</td>"
         Response.Write "<td>"
         Response.Write rs(i).NumericScale
         Response.Write "</td>"
         Response.Write "</tr>"
       Next
       Response.Write "</table>"
    End If
    rs.Close
    Err.Clear
    CreateTableSql = "CREATE TABLE ATAFtestDB ( Pubit char(4) )"
    Set rs = conntemp.Execute(CreateTableSql)
    If Err <> 0 Then
       Response.write "<font color="+qu+"#FF0000"+qu+">"
       Response.Write "Could NOT modify data in your table " + Table +", there must be R/W/C rights in the directory where the database is located<br>"
       Response.Write "Error Number= #<b>" & Err.Number & "</b><br>"
       Response.Write "Error Desc.= <b>" & Err.Description & "</b><br>"
       Response.write "</font>"
    Else
       Response.Write "There is R/W/C rights in the table " + Table
         CreateTableSql = "DROP TABLE ATAFtestDB"
         Set rs = conntemp.Execute(CreateTableSql)
    End If
    %>
    </td></tr>
    <tr><td colspan="2"><font size="4"><b>Testing picture upload capability</b></font></td></tr>
    <tr><td></td><td>
    <%
     Response.Write "Your directory where you upload picture to is : http://"+ Request.ServerVariables("SERVER_NAME") + "/" + imagedir + "<br>"
    Err.Clear
    Set fs = CreateObject("Scripting.FileSystemObject")
    If Err <> 0 Then
       Response.write "<font color="+qu+"#FF0000"+qu+">"
       Response.Write "could NOT create FileSystem scriptiong Object<br>"
       Response.Write "Error Number= #<b>" & Err.Number & "</b><br>"
       Response.Write "Error Desc.= <b>" & Err.Description & "</b><br>"
       Response.write "</font>"
    Else
       Response.Write "Scripting FileSystemObject is OK<br>"
    End If
    Path = Mid(server.mappath(Request.ServerVariables("PATH_INFO")), 1, InStrRev(server.mappath(Request.ServerVariables("PATH_INFO")), "\")) + imagedir
    Path = Replace(Path, "/", "\")
    Path = Path + "ataftest.dat"
    Err.Clear
    Set ts = fs.CreateTextFile(Path, True)
    If Err <> 0 Then
       Response.write "<font color="+qu+"#FF0000"+qu+">"
       Response.Write "Could not write a file to the server, if you want to upload picture there must be R/W/C right in the directory where you upload your pictures to<br>"
       Response.Write "Error Number= #<b>" & Err.Number & "</b><br>"
       Response.Write "Error Desc.= <b>" & Err.Description & "</b><br>"
       Response.write "</font>"
    Else
       Response.Write "You can upload pictures to " + imagedir + "<br>"
       ts.Close
    End If
    %>
    </td></tr>
    </table>
    </body>
    </html>