i have just known the diffrence between the service based database and local db so as per my need i have transfered the project database to local db and i have questioned and found that i just have to replace the connection string which is the main thing in that and nothing i have to add and replace in my code so. now i am getting the error which i dont know how to solve
my code for local database is
SqlConnection con = new SqlConnection();
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source=E
:\project\+project\WindowsFormsApplication1\Database1.sdf";
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
conn.Open();
try
{
// something
}
catch (Exception)
{
MessageBox.Show("ERROR");
}
conn.Close();
}
and error i am getting on the conn.open
A network-related or instance-specific error occurred
while establishing a connection to SQL Server. The server
was not found or was not accessible. Verify that the
instance name is correct and that SQL Server is configured
to allow remote connections. (provider: SQL Network Interfaces,
error: 26 - Error Locating Server/Instance Specified)
You must use
SqlCeConnectionandSqlCeCommandinstead ofSqlConnectionandSqlCommand.Eample: http://www.dotnetperls.com/sqlce