connection string.

B

bbawa1

Hi,

How can I create a connection string in my web config file. If I
create dataset it automatically appars in web config file but what if
I don't create dataseta nd just want to create database into amy
asp.net application and create a connection string.

Thanks
 
P

Peter Bradley

Ysgrifennodd (e-mail address removed):
Hi,

How can I create a connection string in my web config file. If I
create dataset it automatically appars in web config file but what if
I don't create dataseta nd just want to create database into amy
asp.net application and create a connection string.

Thanks

In the class that contacts the database:

using System.Configuration;

....

ConfigurationManager.ConnectionStrings["MyConnStr"].ConnectionString;

In Web.config:

<configuration>
<appSettings/>
<connectionStrings>
<add name="MyConnStr"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=|DataDirectory|\FormsAuthentication.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>

....

</configuration>

HTH


Peter
 

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