Re: MS Access connection and web.config

  • Thread starter Ken Cox [Microsoft MVP]
  • Start date
K

Ken Cox [Microsoft MVP]

In your web.config file, add a key and the correct connection string as
shown below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="connstring"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\thepath\accessdb.mdb;User ID=Admin;Password="
/>
</appSettings>
<system.web>
.....

In your codebehind file, read in the configuration setting:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim strConnection As String
strConnection = _
ConfigurationSettings.AppSettings("connstring")
Label1.Text = "The connection string is " & strConnection
End Sub

You'll have to adjust the Data Source path to suit the location of your
Access file.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top