In this article I
am going to explain how to set up Connectionstring in Web.config file in
asp.net
Implementation:
Open the
web.config of the asp.net application. Before closing the configuration element,
add a new element ConnectionString.
Configure the ConnectionString for Sql
server:
<connectionStrings>
<add
name="con" connectionString="Data Source=vijay-pc;Initial Catalog= database;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
Configure the connectionstring for
MS-access:
<connectionStrings>
<add
name="con" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|databse.accdb;Persist
Security Info=True" providerName="System.Data.OleDb"
/>
</connectionStrings>
Configure the connectionstring for Oracle:
<connectionStrings>
<add name="con" connectionString="Data Source=db;Persist
Security Info=True" providerName="System.Data.OracleClient="/>
</connectionStrings>
Name: Set the value to the name that want to use
to reference the connection string
Connectionstring: Assign a connection string with the
appropriate provider
Note: if project don’t have web.config file
in root, in that case add web.config file to project. A project can have one
web.config file in every folder of project.
0 Comments