Click here to Skip to main content
15,917,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I have MS Visual Studio 2008 with SQL Server Compact. Can anybody help me to establish a connection using web.config file?
Posted

Hello,

there is SqlDatasource tool is present in VS2008 use that and once you create the successful connection then copy the connection string in webconfig(ConnectionString) section

use System.Data.SqlClient.
and use its object to access the conncetion...


still wondering

try to search
Connection string in google.

thanks
sanjeev
 
Share this answer
 
Try this.
<add name="sqlConn" connectionString="DataSource='|DataDirectory|\Database1.sdf'; Password='mypassword'"/>
 
Share this answer
 
v2
 
Share this answer
 
Hi,
use this in the web.config file.
XML
<connectionStrings>
 


    <add name="MedVisitConnectionString" connectionString="Data Source="";Initial Catalog="";User ID="";Password=""" />
    <remove name="MedVisitMembership" />
    <add name="MedVisitMembership" connectionString="Data Source="";Initial Catalog=aspnetdb;User ID="";Password=""" providerName="System.Data.SqlClient" />

  </connectionStrings>




ask if you feeol any doubt in this.
 
Share this answer
 
v3
using System.Data.SqlClient;
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
//execute queries

myConnection.Close();
 
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