Newbie SQlCe Connection question

B

Bob Clegg

Hi,
My First CE App.
SQL CE Version 2.0
Emulator accepted Database creation line and I've added a table using the
Query analyser in the emulator.
But my connection string refuses to connect.
Database was created in the My Computer root directory of the emulator.
Code is :
System.Data.SqlServerCe.SqlCeConnection cn = new
System.Data.SqlServerCe.SqlCeConnection("Data Source= MyDatabase.sdf");

The error generated is a SystemException but the message property of the
exception is an empty string.

I have tried ("Data Source=\\My Computer\\ MyDatabase.sdf");

Same Result.

Thanks

Bob
 
A

Alex Feinman [MVP]

Needs to be an explicit path to the database
System.Data.SqlServerCe.SqlCeConnection cn = new
System.Data.SqlServerCe.SqlCeConnection("Data Source= \\MyDatabase.sdf");
 
B

Bob Clegg

Hi Alex.
Thanks for that.
regards
Bob
Alex Feinman said:
Needs to be an explicit path to the database
System.Data.SqlServerCe.SqlCeConnection cn = new
System.Data.SqlServerCe.SqlCeConnection("Data Source= \\MyDatabase.sdf");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top