Last post Sep 27, 2009 11:44 AM by geekgirl1978
Sep 27, 2009 05:00 AM|geekgirl1978|LINK
I have an asp.net page which displays some data from an access database. It works fine locally using this connection string in web.config:
<add name="connString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|mydatabase.mdb;Jet OLEDB:Database Password=myPassword;" />
The problem occurrs when I try to publish my site to my web server. I want to place my database in a private folder outside of the folder where my pages are. I changed the connection string to the following:
<add name="connString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\private\mydatabase.mdb;Jet OLEDB:Database Password=myPassword;"/>
but it comes up with the error:
Why is it looking at my local c drive? And how do I tell it to look at my server instead? Any help would be appreciated.
This is the code for my page:
Partial Class html_Default
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Repeater1.DataSource = GetDetails("SELECT * FROM Projects WHERE isSampleProject=TRUE")
Catch ex As Exception
Private Function GetDetails(ByVal sqlQuery As String) As DataSet
'create a connection string
Dim dbconn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("connString").ConnectionString)
'create a data adapter
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sqlQuery, dbconn)
'create a new dataset
Dim ds As DataSet = New DataSet
Sep 27, 2009 06:00 AM|hans_v|LINK
Is there a reason that you wa\nt to place the database outside the App_Data folder? If not, just leave it there and use the same connectionstring as you're using locally. Note that this folder is protected by ASP.NET, so it isn't possible to download the
database form there.
If you want to place it somewhere else, just specify the full path. Also make sure that you set the right permissions:
Sep 27, 2009 11:44 AM|geekgirl1978|LINK
Thanks for the reply. I thought I had already tried keeping it in the App_Data folder but obviously I hadn't. It works just fine now.
Thanks a lot!