Solved

Opening .SDF files with SQL Server Express - C#

Posted on 2007-11-30
2
11,559 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
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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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