SQL Compact 2008 Connection String Problem

Posted by Seth on Stack Overflow See other posts from Stack Overflow or by Seth
Published on 2010-06-07T15:06:42Z Indexed on 2010/06/07 15:12 UTC
Read the original article Hit count: 170

Filed under:
|
|

I have the following code to connect to a sql server compact edition 2008:

    private SqlConnection sqlConn;

    public void createConnection()
    {
        String connectionString = @"Data Source=C:\Projects\somefile.sdf;Persist Security Info=False";
        sqlConn = new SqlConnection(connectionString);
        sqlConn.Open();
    }

However, I keep getting the following error when sqlConn.Open() is executed:

"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)"

Does anyone have any ideas what the problem might be? I can create a connection to the db in the database explorer but it doesn't seem to work in code.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server