Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to define attribute in add tag like key and name
and how to use that attribute to connect external DB
Posted

web.config //define like this

C#
<connectionstrings>
   <add name="TestConnectionString" connectionstring="Data Source=.;Initial Catalog=Test;Integrated Security=True">
     providerName="System.Data.SqlClient" />
 </add></connectionstrings>



and .cs files retrieve like this

C#
string conn_string = ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;
 
Share this answer
 
v2
 
Share this answer
 
v2
Comments
Maciej Los 24-Feb-14 4:04am    
+5
Abhinav S 24-Feb-14 5:59am    
Thank you.
XML
<connectionstrings>
    <add name="TestConnectionString" connectionstring="Data Source=192.168.1.2;Initial Catalog=Test;Integrated Security=True">
      providerName="System.Data.SqlClient" />
  </add></connectionstrings>




Here, 192.168.1.2 is the IP address of the other system where your database is situated...
 
Share this answer
 
v2
connectionstring="<b>Data Source=.;Initial Catalog=Test;Integrated Security=True</b>"

how can i get this data?
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900