it is already there in any typical asp.net project i.e. web.config file
and it already stores the connection string that is created using default wizards, you can add your own tag as well
in this file and access it in your C# code,
To access a connection string from web.config file first you can use design view SQL Data Source control using its wizard
you can build up a connection string, and it will ask to save it, if checked a new connection string will be added to this file that
will look like:
-_-
Member
376 Points
1046 Posts
config file
Dec 30, 2012 04:26 PM|LINK
Anil Srivast...
Member
442 Points
292 Posts
Re: config file
Dec 30, 2012 04:36 PM|LINK
1. right click project ->add new item -> web configuration file
OR
Take gridview ->configure data source->
do steps as needed web.config will be created on the fly with all the database settings
usman400
Contributor
3493 Points
721 Posts
Re: config file
Dec 30, 2012 04:46 PM|LINK
it is already there in any typical asp.net project i.e. web.config file
and it already stores the connection string that is created using default wizards, you can add your own tag as well
in this file and access it in your C# code,
To access a connection string from web.config file first you can use design view SQL Data Source control using its wizard
you can build up a connection string, and it will ask to save it, if checked a new connection string will be added to this file that
will look like:
<connectionStrings>
<add name="DBConnectionString" connectionString="Server=YourServerName;Initial Catalog=DatabaseName;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
access it in code behind:
ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString()
You have to add this namespace at top of page:
using System.Configuration;