Click here to Skip to main content
15,909,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have tried to make connection with database using app.config.

and the code is like this:

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="jsl2connection" connectionString="RABIN-PC\SQLEXPRESS;Database=jsl2;"  providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>



but while i run the program , error occured like this:

Keyword not supported: 'rabin-pc\sqlexpress;database'.

can any one help me out ..
please give me and idea how to write correct connection string!!!or please write the correct connection code!!!
Posted

You're missing "server=" at the beginning of the connectionstring attribute.

Further Reading
http://www.connectionstrings.com/[^]
 
Share this answer
 
v2
Comments
thatraja 3-Jul-11 8:24am    
You beat me to it, 5!
try this:


<configuration>
  <connectionstrings>
    <add name="jsl2connection" connectionstring="Data Source=RABIN-PC\SQLEXPRESS;Initial Catalog=jsl2; Integrated Security=True" providername="System.Data.SqlClient" />
  </connectionstrings>
</configuration>


hope this helps :)
 
Share this answer
 
hi,

use can also use sqlDataSouce with that u can select Database and table in this way u can create connection dynamically
 
Share this answer
 

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