locked
Solution in Using MS Access (mdb) on Godaddy (web.config) RRS feed

  • Question

  • User-1666820088 posted

    Hi i am paco

    im from mexico df

    my post this solution in godaddy conect ms access in web.config

    <?xml version="1.0"?>
    <!-- -->
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
        <appSettings/>
        <connectionStrings>
          <!-- FILE DSN -->
          <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Hosting/6702198/html/access_db/css.mdb" providerName="System.Data.OleDb" />
          <!-- MDB FILE-->
         <add name="ConnectionStringODBC" connectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/Hosting/6702198/html/access_db/css.mdb" />
        </connectionStrings>
        <system.web>
            <!-- 
                Set compilation debug="true" to insert debugging 
                symbols into the compiled page. Because this 
                affects performance, set this value to true only 
                during development.
            -->
            <compilation debug="false" />
            <!--
                The <authentication> section enables configuration 
                of the security authentication mode used by 
                ASP.NET to identify an incoming user. 
                <authentication mode="Windows" />
            -->
            
            <customErrors mode="Off"/>
            <!--
                The <customErrors> section enables configuration 
                of what to do if/when an unhandled error occurs 
                during the execution of a request. Specifically, 
                it enables developers to configure html error pages 
                to be displayed in place of a error stack trace.
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
        </system.web>
    </configuration>

    <?xml version="1.0"?>

    <!-- -->

    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

        <appSettings/>

        <connectionStrings>

          <!-- FILE DSN -->

          <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Hosting/0123456/html/access_db/database.mdb" providerName="System.Data.OleDb" />

          <!-- MDB FILE-->

         <add name="ConnectionString" connectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/Hosting/0123456/html/access_db/database.mdb" />

        </connectionStrings>

        <system.web>

            <!-- 

                Set compilation debug="true" to insert debugging 

                symbols into the compiled page. Because this 

                affects performance, set this value to true only 

                during development.

            -->

            <compilation debug="false" />

            <!--

                The <authentication> section enables configuration 

                of the security authentication mode used by 

                ASP.NET to identify an incoming user. 

                <authentication mode="Windows" />

            -->

            

            <customErrors mode="Off"/>

            <!--

                The <customErrors> section enables configuration 

                of what to do if/when an unhandled error occurs 

                during the execution of a request. Specifically, 

                it enables developers to configure html error pages 

                to be displayed in place of a error stack trace.


            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

                <error statusCode="403" redirect="NoAccess.htm" />

                <error statusCode="404" redirect="FileNotFound.htm" />

            </customErrors>

            -->

        </system.web>

    </configuration>



    Tuesday, September 28, 2010 4:07 PM

All replies

  • User-821857111 posted

    I really would not advise putting mdb files anywhere except the App_Data folder otherwise users can browse to them and download them. When you put them in App_Data, make sure that the account under which ASP.NET runs has MODIFY permissions on App_Data otherwise you will end up with Operation must use an Updateable Query errors when trying to insert or update data.

    Finally, your second connection string option which makes use of ODBC via a DSN is strongly discouraged for performance reasons. You should only use Jet with mdb files.

    http://www.mikesdotnetting.com/Article/78/AccessDataSource-SqlDataSource-and-connecting-to-Access-databases-in-ASP.NET


    Tuesday, September 28, 2010 5:33 PM
  • User-1199946673 posted

    I really would not advise putting mdb files anywhere except the App_Data folder otherwise users can browse to them and download them
     

    Mike, I never used Godaddy (and if I read the stories I never ever will!!!!), but I've seen multiple threads talking about Godaddy. It seem they have very strict policies, One of them is that they don't allow Modify permissions. However, They offer a access_db folder outside the root with Modify Permissions, just like in the old (classic ASP) days....

    http://community.godaddy.com/help/article/34

    Tuesday, September 28, 2010 5:58 PM
  • User-821857111 posted

    They offer a access_db folder outside the root with Modify Permissions

    Thanks for pointing that out, hans. You can guess that I have never used GoDaddy either. For anyone else who's concerned, if access_db is outside of the root, it cannot be browsed to.


    Tuesday, September 28, 2010 6:08 PM
  • User-1111283707 posted

    To complete your sample a little more, here is a page to go with it.

    web.config file containing the ConnectionString:

    <configuration>
      <connectionStrings>
        <add name="Sample" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
            Data Source=D:/Hosting/0123456/html/access_db/database.mdb"
            providerName="System.Data.OleDb"/>
      </connectionStrings>
      <!-- ... rest of your web.config -->
    </configuration>

    Sample ASPX page:

    <%@ Page Language="VB" %>
    <html>
     <body>
     <%
      Dim cn As System.Data.OleDb.OleDbConnection = Nothing
      Dim cmd As System.Data.OleDb.OleDbCommand = Nothing
      Dim oDataReader As System.Data.OleDb.OleDbDataReader = Nothing
      Dim sConnectionString As String = ConfigurationManager.ConnectionStrings("Sample").ConnectionString
      Dim tablename As String = "MyTableName"
      Dim sSQLStatement As String = "SELECT TOP 10 * FROM " & tablename & " ORDER BY 1;"

      Try
       cn = New System.Data.OleDb.OleDbConnection(sConnectionString)
       cn.Open()
       cmd = New System.Data.OleDb.OleDbCommand(sSQLStatement, cn)
       Try
        oDataReader = cmd.ExecuteReader
       Catch
        MsgBox("GetOleDbReader:Data Execute Error")
       End Try
      Catch Ex As Exception
       System.Diagnostics.Debug.WriteLine("GetOleDbReader.\n" & Ex.Message)
       Response.Write("GetOleDbReader.\n" & Ex.Message.ToString() & "<hr/>")
      End Try

      If (Not IsNothing(oDataReader)) Then
       If (oDataReader.HasRows) Then
        While (oDataReader.Read)
         Response.Write(oDataReader.GetValue(0).ToString() & "<hr/>")
        End While
       End If
       oDataReader.Close()
       oDataReader = Nothing
      End If
     %>
     </body>
    </html>

    Sunday, October 3, 2010 12:48 PM
  • User-1666820088 posted

    Hi I explain my solution and is working with godaddy.
    Previously I had problems connecting the database (. Mdb), the
    problem was the driver to connect to the database.


    access_db folder is assigned to put the database in MS Access and can not browse this directory, it also serves to create the DSN file

    Sorry for labels to say that I forget to remove the two connections are DSN ms acess

    But this is the solution for access and use godaddy ms.

        <connectionStrings>

          <!-- MDB FILE-->

          <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Hosting/0123456/html/access_db/database.mdb" providerName="System.Data.OleDb" />

          <!-- MDB FILE-->

         <add name="ConnectionString" connectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/Hosting/0123456/html/access_db/database.mdb" />

        </connectionStrings>

    Monday, October 4, 2010 4:05 PM