I getting a SqlException was unhandled error when I try to open the connection to the simple table I may in vs 2010. is there something wrong with my connection string? I copied the string out of the properties of the connection in server explorer. I pasted the full error and code below. Thanks
“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)”
InitializeComponent();
SqlDataReader myDataReader;
SqlConnection myConnection = new SqlConnection(@"DataSource=C:\Developement\KelseysChangeProject\Database1.sdf");
SqlCommand myCommand = new SqlCommand("Select * From ChangeTable", myConnection);
myConnection.Open(); <------ error happens here
myDataReader = myCommand.ExecuteReader();
myDataReader.Close();
myConnection.Close();
.sdf files are for SQL Server CE, which uses a different set of objects, such as
SqlCeConnection(instead ofSqlConnection) like you have. These are within theSystem.Data.SqlServerCenamespace.