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.
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....
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.
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>
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.
None
0 Points
2 Posts
Solution in Using MS Access (mdb) on Godaddy (web.config)
Sep 28, 2010 04:07 PM|pacoasp|LINK
Hi i am paco
im from mexico df
my post this solution in godaddy conect ms access in web.config
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><?xml version="1.0"?></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><!-- --></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <appSettings/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <connectionStrings></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <!-- FILE DSN --></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Hosting/6702198/html/access_db/css.mdb" providerName="System.Data.OleDb" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <!-- MDB FILE--></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <add name="ConnectionStringODBC" connectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ=D:/Hosting/6702198/html/access_db/css.mdb" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </connectionStrings></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <system.web></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <!-- </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> Set compilation debug="true" to insert debugging </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> symbols into the compiled page. Because this </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> affects performance, set this value to true only </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> during development.</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> --></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <compilation debug="false" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <!--</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> The <authentication> section enables configuration </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> of the security authentication mode used by </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> ASP.NET to identify an incoming user. </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <authentication mode="Windows" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> --></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <customErrors mode="Off"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <!--</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> The <customErrors> section enables configuration </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> of what to do if/when an unhandled error occurs </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> during the execution of a request. Specifically, </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> it enables developers to configure html error pages </div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> to be displayed in place of a error stack trace.</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <error statusCode="403" redirect="NoAccess.htm" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> <error statusCode="404" redirect="FileNotFound.htm" /></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </customErrors></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> --></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> </system.web></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></configuration></div> <div></div><?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>
<div></div>
access Access Database - FileDSN in ASP.NET 2.0 Access 2003 Ms access database Access db Access C# VB database godaddy connecting to datasource MS access database odbc ms access mdb web.config
All-Star
194882 Points
28101 Posts
Moderator
Re: Solution in Using MS Access (mdb) on Godaddy (web.config)
Sep 28, 2010 05:33 PM|Mikesdotnetting|LINK
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
All-Star
25756 Points
7014 Posts
Re: Solution in Using MS Access (mdb) on Godaddy (web.config)
Sep 28, 2010 05:58 PM|hans_v|LINK
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
All-Star
194882 Points
28101 Posts
Moderator
Re: Solution in Using MS Access (mdb) on Godaddy (web.config)
Sep 28, 2010 06:08 PM|Mikesdotnetting|LINK
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.
None
0 Points
1 Post
Re: Solution in Using MS Access (mdb) on Godaddy (web.config)
Oct 03, 2010 12:48 PM|konigmann|LINK
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>
ASP GoDaddy access_db
None
0 Points
2 Posts
Re: Solution in Using MS Access (mdb) on Godaddy (web.config)
Oct 04, 2010 04:05 PM|pacoasp|LINK
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>
asp.NET 2.0 c# website C# Classes Asp.NET 3.5 MS Access Databases web.Config