connectionStrings question

C

Craig Buchanan

I have configure my database's connection string the web.config's:

<connectionStrings>
<add name="MyDatabase"
providerName="Microsoft.Jet.OLEDB.4.0"
connectionString="Data Source=.\App_Data\MyDatabase.mdb;Persist
Security Info=False"
/>

Moreover, I can retrieve this setting using this code:

Dim settings As ConnectionStringSettings =
ConfigurationManager.ConnectionStrings("MyDatabase")
Dim cn As New OleDbConnection(String.Concat("Provider=",
settings.ProviderName, ";", settings.ConnectionString))

I have two questions:
1). Is there another way to get the 'full' connection string, rather
than having to concatinate the ProviderName and ConnectionString properties?
2). The '.\App_Data\MyDatabase.mdb' resolves to 'C:\Program
Files\Microsoft\Visual Studio 8\Common7\IDE\App_Data\MyDatabase.mdb'. I
would like this path to be relative to WebService's directory. Is there
a way to do this?

Thanks for your time,

Craig Buchanan
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top