Solved

Opening .SDF files with SQL Server Express - C#

Posted on 2007-11-30
2
11,549 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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