Databackup / reuse in case og structure change

  • Thread starter Finn Stampe Mikkelsen
  • Start date
F

Finn Stampe Mikkelsen

Hi

I'm using an local (SDF) databse end need to create a data backup feature in
code.

Is there any easy way to go about this or is hard-coding the only way to go?

Also, is there a way easily to reuse data in case of change in data
structure? Example: One table has a given structure. Now a field is added to
the mix. The rest of the fields are unchanged. Is there an easy way to reuse
the old data, leaving this new field empty or must the data be discarded??

I know that dataplanning is very important, but i have an application that
has been running for years and now new field needs to be added.. Backup so
far has been done with ms-backup, but i would like to explore the
possibillity of incorporating a backup routine into the app.

TIA

/FStampe
--
Der er 10 slags mennesker - Dem som forstår binær og dem som ikke gør.
There are 10 kinds of people. Those who understand binary and those who
don't.
Es gibt 10 Arten von Menschen. Die, die Binär verstehen, bzw. die, die es
nicht tuhen.
 
P

Patrice

Hello,
I'm using an local (SDF) databse end need to create a data backup feature
in code.

With SDF, it should be just copying the file. What is the problem you get ?
Also, is there a way easily to reuse data in case of change in data
structure? Example: One table has a given structure. Now a field is added
to the mix. The rest of the fields are unchanged. Is there an easy way to
reuse the old data, leaving this new field empty or must the data be
discarded??

This is an ALTER TABLE statement. Once again I'm not familiar with SDF but
generally for SQL Server :
- added field are set to NULL or if they are NOT NULL with a default value
they are given this value.
 
F

Finn Stampe Mikkelsen

Patrice said:
Hello,


With SDF, it should be just copying the file. What is the problem you get
?


This is an ALTER TABLE statement. Once again I'm not familiar with SDF but
generally for SQL Server :
- added field are set to NULL or if they are NOT NULL with a default value
they are given this value.

Hi Patrice...

Here's the situation in details..

I'm currently updating an application, that has been running for some time.
The DB needs an update with some new fields. So i need to back the data in
the database, not the actual database file. After installing the update for
the app, the data needs to be reintroduced to the now empty database and the
new fields left empty..

So a routine to read out the data to f.ex. a csv file, incl. the field names
and the field-def's and a routine to read back data from this csv file into
the database using sql insert but only inserting the data known from the
previous database.

I wan't to do this, to accomodate later updates where database may change
again.

What i'm looking for is, if there is any intelligent way to do that or if i
need to hard-code this from schratch. No need to reinvent the wheel...

Do you se my "problem"?? I have not any code that gives me a problem and no
need to alter databases from code...

/FStampe
 
P

Patrice

So a routine to read out the data to f.ex. a csv file, incl. the field
names and the field-def's and a routine to read back data from this csv
file into the database using sql insert but only inserting the data known
from the previous database.

Not sure for producing the file (you'll likely have to code). For insert
this could be perhaps done with BULKINSERT (not sure if supported on
Compact). Another option could be to use a dataset and save/read those data
as an XML file. The "SQL Publishing Wizard" does this (but once again this
is tool that is likely not provided in a default install and not really
intended for this usage (deployement where SQL Server is not directly made
available by your web hosting service)).
Do you se my "problem"?? I have not any code that gives me a problem and
no need to alter databases from code...

This would be still likely my personal preference. IMHO it is much simpler
to just update the db schema using the appropriate ALTER statement(s) rather
than to extract/reinsert all the data into a new db...

Sorry for the poor help...
 

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