All embedded databases fail to open connections

Posted by rsteckly on Stack Overflow See other posts from Stack Overflow or by rsteckly
Published on 2010-05-31T05:20:22Z Indexed on 2010/05/31 5:22 UTC
Read the original article Hit count: 368

Filed under:
|
|
|
|

Hi,

I'm working on a winforms desktop application that needs to store data. I made the really bad decision to try and embed a database. I've tried:

  • SQLite
  • VistaDB
  • SQL Server Compact

In each case, I was able to generate a Entity Framework Model over the basic schema I've created. I have an event that adds data that I've been using to test these databases.

Well, I kept adding a new record using EF and finding it didn't actually insert a record. In debugging, I checked the context object to see what was happening. It turns out that it is saying "the underlying provider failed to open," or something to that effect. It was not throwing an exception, just not inserting a record.

The same thing has happened for all 3 embedded databases--prompting me to get it through my dense head that there has to be something wrong with my configuration.

Well, I tried to write some basic sql using a sqlconnection and sqlcommand. This time it throws an exception. In the SQL Server Compact case, it now says:

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)

I thought perhaps a problem was the path in app.Config. So I changed the connection string to:

Note that I simplified the path away from anything that might have spaces and avoided using the Data Directory nonsense that causes problem when the debugging directory does not match the preconfigured value for the data directory. I'm running Windows 7; I thought perhaps it might be an access issue--so I tried running VS 2010 in Administrator mode. No luck. I also installed Sql Server Compact SP2, thinking this might be a bug. No luck.

Anyway, I'm ready to pull my hair out. I'm on a tight deadline for this thing and didn't expect to spend the day trying to figure out what is going on.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about sql