Link to home
Start Free TrialLog in
Avatar of GavinS
GavinS

asked on

Opening .SDF files with SQL Server Express - C#

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
ASKER CERTIFIED SOLUTION
Avatar of imitchie
imitchie
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GavinS
GavinS

ASKER

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