views:

16

answers:

1

Hi, I've created a Database in my project with one simple table. The database is stored locally and has a .sdf extension. On my computer I have installed SQL Server 2008, there is also SQL Server 2000 but that is a network server which I don't want to work on.

I want to use the local database, which I created within the VS IDE and I tried a simple connection but it didn't work:

SqlConnection conn = new SqlConnection();
            SqlConnectionStringBuilder connBuilder = new SqlConnectionStringBuilder();
            connBuilder.DataSource = @"C:\Documents and Settings\abc\My Documents\Downloads\FileWatcherDemo\FileWatcherDemo\WindowsFormsApplication1\Database1.sdf";
            connBuilder.InitialCatalog = "Database1";
            conn.ConnectionString = connBuilder.ConnectionString;
            conn.Open();

The error I get is after I attempt to open the connection is ->

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)

Thanks.

A: 

Ok, found the answer, instead of using SqlConnection I must use SqlCeConnection and take out the Initial Catalog property which is unnecessary. Cheers.

dimitarie