[2005] Defining a main database path
The website I'm developing has many Gridviews ,Detailviews and so many Access Data Sources. The path to all my access database files is :
~/DB/AccessDB.MDB
when I need to deploy my website , I need to change this path to point to the directory where I'm allowed to keep my access files , sometimes like :
D:/somewhere/DB/AccessDB.MDB
The question is , how can I specifiy a single path for all my gridviews , detailviews and access data sources ?
I thought of using a session to store the path and use it all over the website, so I would simply change the session to "~/DB/AccessDB.MDB" on my computer , and right before I deploy the site , I change the session to "D:/somewhere/DB/AccessDB.MDB"
Is it a good idea?
Re: [2005] Defining a main database path
If you're using SQL, there's no pointing involved. All the database stuff is secured against users except local users, which includes the IIS process and ASP.NET. Create a connection string in your web.config file if you haven't already, and tell it which database to use and give it the right credentials. For every object that's data driven, use that connection string in the data source. All handled through ASP.
Re: [2005] Defining a main database path
ok This is the connection string I found in my web.config file
Code:
<connectionStrings>
<add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|AccessDB.mdb;Persist Security Info=True"
providerName="System.Data.OleDb" />
</connectionStrings>
now one of the gridviews is using the following access data source :
Code:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/AccessDB.mdb"
what changes should I make to serve that idea?
Re: [2005] Defining a main database path
First, the connection string is missing information. How can it connect without a login to the database? Try something more like this:
xml Code:
<add connectionString="Server=[server name];Database=[database name];User ID=sa;Password=[database admin login]" name="[a name to use throughout the app]" providerName="Microsoft.Jet.OLEDB.4.0" />
I use entirely SQL databases, so my objects are slightly different, but the concept should be the same:
xml Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:[name of connection string] %>"