Relative path to Access database in .net 2

T

Thomas M

I'm trying to read from an Access database using an SqlDataSource and
displaying the retrieved data with a DataList, in asp.net 2.
I want to use a relative path to the .MDB file.
However, I get this error:
"The connection name was not found in the applications configuration
or the connection string is empty"

The .aspx file:
<asp:SqlDataSource ID="DataSourceLinks" runat="server"
ConnectionString="<%$ ConnectionStrings:DBforbLinks %>"
ProviderName="System.Data.Odbc" SelectCommand="SELECT blah
FROM blah">
</asp:SqlDataSource>

<asp:DataList ID="DataList1" runat="server"
DataSourceID="DataSourceLinks">
</asp:DataList>

The web.config file:
<appSettings>
<connectionStrings>
<add name="DBForbLinks"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=~/myFolder/myDB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</appSettings>

I've removed all the styling-code etc. in the above code.

So, what's wrong?
 
G

Guest

Hi Thomas,

In connection string, Data Source value should be a physical path rather
than a virtual path.

HTH


Elton Wang
 
T

Thomas M

In connection string, Data Source value should be a physical path rather
than a virtual path.

Hi Elton.

I want to use a relative path, because the path to the database differ
between my development workstation and the production server.
 
P

Paul Clement

¤ On Sun, 22 Jan 2006 13:21:02 -0800, "Elton W"
¤
¤ >In connection string, Data Source value should be a physical path rather
¤ >than a virtual path.
¤
¤ Hi Elton.
¤
¤ I want to use a relative path, because the path to the database differ
¤ between my development workstation and the production server.

You can't use a relative path in the connection string. You must build the complete physical path,
which you should be able to do based upon your application location or config file setting.


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top