since we give connection in aspx.cs file we want to give connection in web config file .how to give connection.
+2
A:
Do you mean connection string?
If so then what I do is have my web.config file like this;
<connectionStrings configSource="ConnectionStrings.config" />
And then I have a connectionstrings.config file;
<connectionStrings>
<add name="Production" connectionString="Data Source=MYDS; Initial Catalog=InitCat; User ID=UID; Password='Password';"
providerName="System.Data.SqlClient" />
<add name="PreProduction" connectionString="Data Source=MYDS; Initial Catalog=InitCat; User ID=UID; Password='Password';"
providerName="System.Data.SqlClient" />
<add name="Development" connectionString="Data Source=MYDS; Initial Catalog=InitCat; User ID=UID; Password='Password';"
providerName="System.Data.SqlClient" />
</connectionStrings>
Then, based on a flag, I load the relevant connection string using;
System.Configuration.ConfigurationManager.ConnectionStrings["PrePorduction"].ConnectionString
griegs
2010-09-06 04:48:46
ok its working............
2010-09-06 12:22:23
A:
You can use the ConnectionStrings element in the Configuration settings. If you want to know the specific format for different providers and various options that can be specified in the connection string property have a look at connectionstrings.com
Nilesh Gule
2010-09-06 04:59:14
I don't think this is what's being asked as the OP says they have the connection in the aspx.cs file. Difficult to tell what is being asked though
griegs
2010-09-06 05:01:48