Solved

Opening .SDF files with SQL Server Express - C#

Posted on 2007-11-30
2
11,569 Views
Last Modified: 2013-12-16
Hi Guys,
I'm trying to open a .SDF datadase file. The file was previously created on a PDA and subsequently transfered to my laptop where I have SQL Server Express installed.

In the application on my laptop, I define the SQL connection like this:
    String FileName="C:\\Datafolder\\MyDataFile.sdf";
    ShiftFileConnection = new SqlConnection("server=SCAMLT001\\SQLEXPRESS;"
                                                                     + "Trusted_Connection=yes;"
                                                                     + "data Source=" + FileName);
   ShiftFileConnection.Open();

When I call the .Open() method, an exception occurs with the following error message:
"An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

I suspect I just haven't got the connect string quite right, but I've tried numerious connect strings without any success.   - Can someone kindly review my connect string and point out the error.   -Thanks
0
Comment
Question by:GavinS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
imitchie earned 250 total points
ID: 20386611
SQL Server express cannot open .SDF files, which are for SQL Server CE. You need to use the SQL CE libraries to open them instead.
0
 

Author Closing Comment

by:GavinS
ID: 31623403
Thanks imitchie:
That fixed it. I didn't think the SQLce libraries would work for conventional windows applications.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question