Copying an open SQLCE-Database

  • Thread starter Thread starter Trollpower
  • Start date Start date
T

Trollpower

Dear NG,

i need to copy/read an open *.sdf file on the device to a custom
directory. But i get an errormessage which says that there is a
filesharing violation or that this file cant be accessed.

If i open a textfile, i still can copy it to some other location on
the device, but im not able to copy a databasefile which is opened.

Does anyone has a hint how to copy this file regardless of its current
state of connection/opening? BTW I cant close the databaseconnection
due to some different reasons, so i need to copy the file regardless
if it is open or not.

Thanks for your hints in advance

Jens
 
Hi,

I do not think it is possible atleast with the current SQLCE 2.0 version.

Best Regards,
Y. Sivaram
 
AFAIK, that's not doable. However, the issue of "can't close the
databaseconnection due to some different reasons'... you'll probably want to
take a look and that and figure out why they aren't closing. If you can't
close them then you aren't going to be able to open any new ones and that'll
probably present some issues. If you mean that you need to DB open to
perform some processing, then you may want to reconsider your data access
strategy. Whatever you need to do can be done to a dataset or retrieved
from a dataset so that will allow you to close your connection. Moroever,
you can load the db into a dataaset in the first place (just to show you an
illustration) and serialize and deserialize it using the .WriteXML and
ReadXML methods of the dataset Submitting the data back to SQLCE only when
you are done with the session. In doing so, there'd be NO pressure
whatsoever on CE throughout the whole session.

HTH,

Bill
 
First, thanks for your reply.

The reason why i cant close the database is, that i use some kind of
library which manages the database-access. The advantage of this library
is, that i dont need to know the exact tablenames, columnnames and even
not writing any sql-statements. The problem with this library is, that
it holds the database open for as long as the application is running.

During runtime of the application we/I want to be able to get the
database of the internet from the device. This is neccessary because
sometimes there are some issues with the data in the database and we
cant tell the user to bring his device in, so that we can check the
data. So i wanted to copy the database to a custom directory, zipping it
and then send over http-put to our server. We cant also tell the users
(most of them are close to dumb in technical issues) how to copy the
database, zipping it and send it with a tool to our servers. In this
case the only thing a user has to do is to click a button, and a small
library of mine is doing the rest.

So, again, if anyone knows a way of copying an open database, i would
greatly appreciate it. I hope the reason for me to need an open database
to be copied becomes clear now...

Greetings

Jens
 
I understand what you are saying, but at some point, there's very little
noteworthy distinction between hitting a CE database and a dataset once
things have started. Another option is to create a dataset, then fill it
with the db. Set AcceptChangesDuringFill to false on the adapter. Then,
you can use that dataset, Point to a different 'backup' database and fire
dataAdapter.Update. Setting AcceptChangesDuringFill will make the rowstate
of each of them as Added, so when you fire the update with an adapter
pointing to another DB (which you can create on the fly), it will populate
another table with the saem data as in your original database.
 
Thanks William for your reply,

thats a nice idea which i will try. I report back if i have any news.

Thanks again

Jens
 
Back
Top