connection string.

  • Thread starter Thread starter bbawa1
  • Start date Start date
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
 
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
 
Back
Top