Link to home
Start Free TrialLog in
Avatar of JoeBo747
JoeBo747

asked on

Data Connection Error

Hi Experts

Running through a tutorial on SQL compact 2005 (see http://msdn2.microsoft.com/en-gb/library/bb219484.aspx) I have completed the project until the debug stage the I get an sqlce exception:

System.Data.SqlServerCe.SqlCeException was unhandled
  HResult=-2147467259
  Message="The file name is not valid. Check the file name for the database. [ File name = |DataDirectory|\Northwind.sdf ]"
  NativeError=25010
  Source="SQL Server 2005 Mobile Edition ADO.NET Data Provider" etc. &&&&..
 
Have I a missing reference, the project builds the data source exists and the connection tests properly.

Any Help appreciated,
Joe
Avatar of naspinski
naspinski
Flag of United States of America image

shouldn't you be looking for the northwind.mdf?  it shows 'sdf'
"Your app needs to look for the sdf file somewhere on the device. Most people either use the same folder that the app is running from or a location on a storage card.", http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.pocketpc.developer&tid=6e060f74-cfd3-44c5-a059-9694fa47a796&p=1

"The path is not valid. Check the directory for the database.", http://msdn2.microsoft.com/en-us/library/ms171879.aspx
Avatar of JoeBo747
JoeBo747

ASKER

Hi
Thanks for your replies, I have downloaded the project companion files and these reside on the desktop, these files include the Northwind.sdf file which the tutorial walks throught making a connection to. As I read this(please correct me if I am wrong.)

connection instructions below:
Figure 5. Adding a connection

Select the file C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile\v3.0\Northwind.sdf in the file-selection dialog box and click Open to select the database.
On the Add Connection dialog, click Test Connection to verify that the database connection is setup properly. If the database file exists and SQL Server Compact Edition has been properly installed, then a dialog box informs you that the connection succeeded.
Click OK to dismiss the Test Connection Succeeded dialog box.
Click OK on the Add Connection dialog box now that you have successfully tested the connection.
You can now expand the Connection string on the Choose Your Data Connection dialog box to view the connection string that has been generated, as shown in Figure 6.

Do I also need the sdf file on the mobile device?

Regards,
Joe
ASKER CERTIFIED SOLUTION
Avatar of gnoon
gnoon
Flag of Thailand 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
Make sure the sdf is a part of your project. Its Build Action should be set as Content and change the path in your code to something like "\Program Files\Your Project\Northwind.sdf".