I'm developing a desktop C# app that uses SQL Everywhere as an embedded database.
I generated strongly typed DataSet and use that to populate a DataGrid on my app.
When the app first loads, it populates the DataGrid with a line like this:
this.sTORE_INV_LNTableAdapter.Fill(this.inventoriesDataSet.STORE_INV_LN);
That all works fine. Later on, after adding more data to the database (through reading a csv file), I wanted to refresh the display on the DataGrid.
I used the same line of code:
this.sTORE_INV_LNTableAdapter.Fill(this.inventoriesDataSet.STORE_INV_LN);
however, this time, the following exception was thrown:
The database file cannot be found. Check the path to the database. [ File name = .\\Inventories.sdf ]
Does anyone know what may be going on? I saw this article about a bug in VS 2005 when using strongly typed DataSets (http://channel9.msdn.com/wiki/default.aspx/MobileDeveloper.DatabaseCannotBeFoundErrorInTypedDataset)
but that doesn't seem to apply here.
The connection string is identical both times that line of code is called so I'm a bit baffled with what's going on.
Any help would be appreciated. Thanks,
Jose
Windows CE does not support relative paths you're trying to use. You must specify correct absolute path to the database located on device file system.
Also keep in mind Windows CE does not have drive letters and can't see your desktop's C: (D:, etc) drive as many developers seem to believe.
|||I'm not running this on Windows CE. I'm trying out the new SQL Server Everywhere and using it on Windows XP.Thanks though.|||
If file can not be found that's probably because it can't be found. You can use File.Exists() to verify that.
|||Thanks for the input!!It sounds so simple and yet I hadn't thought about that. I kept looking for the complicated answer.
It turns out, my database file was there all along. The problem was, after opening and reading the CSV files to import into the db, the next time I tried to access the db the app was looking for the db file in the same directory where my CSVs where...and of course, it wasn't finding it.
So now, after reading a CSV and prior to re-querying the db, I use Directory.SetCurrentDirectory() to reset where the app looks for its db.
Thanks for the help, I had been stumped by this for a week.
-Jose|||
this one has had me scratching my head for a day so I'm glad I haven't spent a week...
I'm using a separate project as a class library with a *.sdf database so it can be re-used for several projects.
I had the exact problem, everything was good until I opened OpenFileDialog(), then things went south after that.
Just a note to your solution... (maybe you do this already)...but you can assign the OpenFileDialog.RestoreDirectory flag to true and then after it closes the original directory will be restored prior to the open dialog....that way you don't need the Directory.SetCurrentDirectory.
fileChooser = new OpenFileDialog();
fileChooser.RestoreDirectory = true;
gl
No comments:
Post a Comment