Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Windows forms application and database back-up

Reply
 
Old 01-28-2009   #1 (permalink)
James Page


 
 

Windows forms application and database back-up

Hi all - hope this is the right forum!

I have a simple vb.net windows forms application which uses data from an
underlying sql express database.

It is deployed in a single user environment and the sql express package is
installed in the default location.

I want to be able to allow the user to backup and restore the underlying
..mdf datafile.

Can anyone give me a couple of pointers on the best way to achieve this?


Many thanks


My System SpecsSystem Spec
Old 01-28-2009   #2 (permalink)
Cor Ligthert[MVP]


 
 

Re: Windows forms application and database back-up

James,

You can always simple use a simple File.Copy for this, (and copy the LDF
file as well)

Set your original database on a for the user accessable place to make it
even easier.

http://msdn.microsoft.com/en-us/libr...file.copy.aspx

Cor


"James Page" <JamesPage@xxxxxx> wrote in message
news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
Quote:

> Hi all - hope this is the right forum!
>
> I have a simple vb.net windows forms application which uses data from an
> underlying sql express database.
>
> It is deployed in a single user environment and the sql express package is
> installed in the default location.
>
> I want to be able to allow the user to backup and restore the underlying
> .mdf datafile.
>
> Can anyone give me a couple of pointers on the best way to achieve this?
>
>
> Many thanks
>
My System SpecsSystem Spec
Old 01-28-2009   #3 (permalink)
Norman Yuan


 
 

Re: Windows forms application and database back-up

If the local SQL Server Express is running (meaning *.mdf/*.ldf is attached
to the SQL Server instance), the files cannot be copied.

To the OP:

Depending on how the user logs in to the SQL Server instance, if he/she has
the permission to do the backup/restore, then you can have your app to run
BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the backup. YOu
can also look into SMO object model to incorporate your app to do the
backup/restore.

The other option would be to use SQL Server Express' USER INSTANCE, to
which, the user do not have to have local admin rigth to attach database to
SQL Server Express instance. With USER INSTANCE, you can get the *.mdf file
easily attached to SQL Server Express at begining of your app and detached
and a backup copy created when your app is done.

However, be warned, USER INSTANCE is an advanced feature and only available
to SQL Server Express2005/8, and rumor has it that USER INSTANCE feature
will be dropped from next SQL Server version, because it causes more trouble
(due to the lack of understanding, IMO) than benefit.

"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
news:u%231F34SgJHA.4868@xxxxxx
Quote:

> James,
>
> You can always simple use a simple File.Copy for this, (and copy the LDF
> file as well)
>
> Set your original database on a for the user accessable place to make it
> even easier.
>
> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
>
> Cor
>
>
> "James Page" <JamesPage@xxxxxx> wrote in message
> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
Quote:

>> Hi all - hope this is the right forum!
>>
>> I have a simple vb.net windows forms application which uses data from an
>> underlying sql express database.
>>
>> It is deployed in a single user environment and the sql express package
>> is
>> installed in the default location.
>>
>> I want to be able to allow the user to backup and restore the underlying
>> .mdf datafile.
>>
>> Can anyone give me a couple of pointers on the best way to achieve this?
>>
>>
>> Many thanks
>>
>
My System SpecsSystem Spec
Old 01-29-2009   #4 (permalink)
Cor Ligthert[MVP]


 
 

Re: Windows forms application and database back-up

Norman,

Why should it be running in a single user operation?

What you write is valid as it is running as multi user source, but as it is
single user like the OP wrote, than in my idea simple make copies has the
same effect.

I was also going for the backup/restore, but rejected that because it has in
my idea no advantages in a single user situation.

Cor


"Norman Yuan" <FakeName@xxxxxx> wrote in message
news:ugT5pQXgJHA.4900@xxxxxx
Quote:

> If the local SQL Server Express is running (meaning *.mdf/*.ldf is
> attached to the SQL Server instance), the files cannot be copied.
>
> To the OP:
>
> Depending on how the user logs in to the SQL Server instance, if he/she
> has the permission to do the backup/restore, then you can have your app to
> run BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the backup.
> YOu can also look into SMO object model to incorporate your app to do the
> backup/restore.
>
> The other option would be to use SQL Server Express' USER INSTANCE, to
> which, the user do not have to have local admin rigth to attach database
> to SQL Server Express instance. With USER INSTANCE, you can get the *.mdf
> file easily attached to SQL Server Express at begining of your app and
> detached and a backup copy created when your app is done.
>
> However, be warned, USER INSTANCE is an advanced feature and only
> available to SQL Server Express2005/8, and rumor has it that USER INSTANCE
> feature will be dropped from next SQL Server version, because it causes
> more trouble (due to the lack of understanding, IMO) than benefit.
>
> "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
> news:u%231F34SgJHA.4868@xxxxxx
Quote:

>> James,
>>
>> You can always simple use a simple File.Copy for this, (and copy the LDF
>> file as well)
>>
>> Set your original database on a for the user accessable place to make it
>> even easier.
>>
>> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
>>
>> Cor
>>
>>
>> "James Page" <JamesPage@xxxxxx> wrote in message
>> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
Quote:

>>> Hi all - hope this is the right forum!
>>>
>>> I have a simple vb.net windows forms application which uses data from an
>>> underlying sql express database.
>>>
>>> It is deployed in a single user environment and the sql express package
>>> is
>>> installed in the default location.
>>>
>>> I want to be able to allow the user to backup and restore the underlying
>>> .mdf datafile.
>>>
>>> Can anyone give me a couple of pointers on the best way to achieve this?
>>>
>>>
>>> Many thanks
>>>
>>
>
My System SpecsSystem Spec
Old 01-29-2009   #5 (permalink)
James Page


 
 

Re: Windows forms application and database back-up

Thanks for that Cor.

The whole idea was that in case of a serious computer crash, or worse, the
user will have a copy of the database files to reinstate.

So will a simple file copy be the best approach or should I consider a
backup and restore option so that the user could manage the restoration of
lost data - say in the case of a os or application reinstall or the purchase
of a new pc?

I want to create an application that is as far as possible self managing -
i.e. won't require me to get involved if the user chooses to change his pc -
just merely reinstalls the application and 'restores' the backed up database
files from within the app.

Thanks in advance.

"Cor Ligthert[MVP]" wrote:
Quote:

> Norman,
>
> Why should it be running in a single user operation?
>
> What you write is valid as it is running as multi user source, but as it is
> single user like the OP wrote, than in my idea simple make copies has the
> same effect.
>
> I was also going for the backup/restore, but rejected that because it has in
> my idea no advantages in a single user situation.
>
> Cor
>
>
> "Norman Yuan" <FakeName@xxxxxx> wrote in message
> news:ugT5pQXgJHA.4900@xxxxxx
Quote:

> > If the local SQL Server Express is running (meaning *.mdf/*.ldf is
> > attached to the SQL Server instance), the files cannot be copied.
> >
> > To the OP:
> >
> > Depending on how the user logs in to the SQL Server instance, if he/she
> > has the permission to do the backup/restore, then you can have your app to
> > run BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the backup.
> > YOu can also look into SMO object model to incorporate your app to do the
> > backup/restore.
> >
> > The other option would be to use SQL Server Express' USER INSTANCE, to
> > which, the user do not have to have local admin rigth to attach database
> > to SQL Server Express instance. With USER INSTANCE, you can get the *.mdf
> > file easily attached to SQL Server Express at begining of your app and
> > detached and a backup copy created when your app is done.
> >
> > However, be warned, USER INSTANCE is an advanced feature and only
> > available to SQL Server Express2005/8, and rumor has it that USER INSTANCE
> > feature will be dropped from next SQL Server version, because it causes
> > more trouble (due to the lack of understanding, IMO) than benefit.
> >
> > "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
> > news:u%231F34SgJHA.4868@xxxxxx
Quote:

> >> James,
> >>
> >> You can always simple use a simple File.Copy for this, (and copy the LDF
> >> file as well)
> >>
> >> Set your original database on a for the user accessable place to make it
> >> even easier.
> >>
> >> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
> >>
> >> Cor
> >>
> >>
> >> "James Page" <JamesPage@xxxxxx> wrote in message
> >> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
> >>> Hi all - hope this is the right forum!
> >>>
> >>> I have a simple vb.net windows forms application which uses data from an
> >>> underlying sql express database.
> >>>
> >>> It is deployed in a single user environment and the sql express package
> >>> is
> >>> installed in the default location.
> >>>
> >>> I want to be able to allow the user to backup and restore the underlying
> >>> .mdf datafile.
> >>>
> >>> Can anyone give me a couple of pointers on the best way to achieve this?
> >>>
> >>>
> >>> Many thanks
> >>>
> >>
> >
>
>
My System SpecsSystem Spec
Old 01-29-2009   #6 (permalink)
Norman Yuan


 
 

Re: Windows forms application and database back-up

I may read the OP message wrong. But what I said is correct: the *.mdf
cannot be copied if it is attached to SQL Server/Express. If the OP want to
use "file copy" to back up the database, he has to detach the database from
SQL Server/Express first, regardless it is single user or not.

If the OP meant to get *.mdf from somewhere to the said coputer, of course
it is "File Copy".

"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
news:uYfhSwdgJHA.1172@xxxxxx
Quote:

> Norman,
>
> Why should it be running in a single user operation?
>
> What you write is valid as it is running as multi user source, but as it
> is single user like the OP wrote, than in my idea simple make copies has
> the same effect.
>
> I was also going for the backup/restore, but rejected that because it has
> in my idea no advantages in a single user situation.
>
> Cor
>
>
> "Norman Yuan" <FakeName@xxxxxx> wrote in message
> news:ugT5pQXgJHA.4900@xxxxxx
Quote:

>> If the local SQL Server Express is running (meaning *.mdf/*.ldf is
>> attached to the SQL Server instance), the files cannot be copied.
>>
>> To the OP:
>>
>> Depending on how the user logs in to the SQL Server instance, if he/she
>> has the permission to do the backup/restore, then you can have your app
>> to run BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the
>> backup. YOu can also look into SMO object model to incorporate your app
>> to do the backup/restore.
>>
>> The other option would be to use SQL Server Express' USER INSTANCE, to
>> which, the user do not have to have local admin rigth to attach database
>> to SQL Server Express instance. With USER INSTANCE, you can get the *.mdf
>> file easily attached to SQL Server Express at begining of your app and
>> detached and a backup copy created when your app is done.
>>
>> However, be warned, USER INSTANCE is an advanced feature and only
>> available to SQL Server Express2005/8, and rumor has it that USER
>> INSTANCE feature will be dropped from next SQL Server version, because it
>> causes more trouble (due to the lack of understanding, IMO) than benefit.
>>
>> "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
>> news:u%231F34SgJHA.4868@xxxxxx
Quote:

>>> James,
>>>
>>> You can always simple use a simple File.Copy for this, (and copy the LDF
>>> file as well)
>>>
>>> Set your original database on a for the user accessable place to make it
>>> even easier.
>>>
>>> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
>>>
>>> Cor
>>>
>>>
>>> "James Page" <JamesPage@xxxxxx> wrote in message
>>> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
>>>> Hi all - hope this is the right forum!
>>>>
>>>> I have a simple vb.net windows forms application which uses data from
>>>> an
>>>> underlying sql express database.
>>>>
>>>> It is deployed in a single user environment and the sql express package
>>>> is
>>>> installed in the default location.
>>>>
>>>> I want to be able to allow the user to backup and restore the
>>>> underlying
>>>> .mdf datafile.
>>>>
>>>> Can anyone give me a couple of pointers on the best way to achieve
>>>> this?
>>>>
>>>>
>>>> Many thanks
>>>>
>>>
>>
>
My System SpecsSystem Spec
Old 01-29-2009   #7 (permalink)
Cor Ligthert[MVP]


 
 

Re: Windows forms application and database back-up

James,

I can not decide that for you. With the information you have given me, I
would probably only tell to the user that he has to made backups using the
normal OS functions from the data directory (and give him that) on regular
base.

However, I don't by instance not know the law in your situation, so it is
completely up to you.

Cor


"James Page" <JamesPage@xxxxxx> wrote in message
news:17C3AE05-A9B9-4616-BD3C-A5127CD136F3@xxxxxx
Quote:

> Thanks for that Cor.
>
> The whole idea was that in case of a serious computer crash, or worse, the
> user will have a copy of the database files to reinstate.
>
> So will a simple file copy be the best approach or should I consider a
> backup and restore option so that the user could manage the restoration of
> lost data - say in the case of a os or application reinstall or the
> purchase
> of a new pc?
>
> I want to create an application that is as far as possible self
> anaging -
> i.e. won't require me to get involved if the user chooses to change his
> pc -
> just merely reinstalls the application and 'restores' the backed up
> database
> files from within the app.
>
> Thanks in advance.
>
> "Cor Ligthert[MVP]" wrote:
>
Quote:

>> Norman,
>>
>> Why should it be running in a single user operation?
>>
>> What you write is valid as it is running as multi user source, but as it
>> is
>> single user like the OP wrote, than in my idea simple make copies has the
>> same effect.
>>
>> I was also going for the backup/restore, but rejected that because it has
>> in
>> my idea no advantages in a single user situation.
>>
>> Cor
>>
>>
>> "Norman Yuan" <FakeName@xxxxxx> wrote in message
>> news:ugT5pQXgJHA.4900@xxxxxx
Quote:

>> > If the local SQL Server Express is running (meaning *.mdf/*.ldf is
>> > attached to the SQL Server instance), the files cannot be copied.
>> >
>> > To the OP:
>> >
>> > Depending on how the user logs in to the SQL Server instance, if he/she
>> > has the permission to do the backup/restore, then you can have your app
>> > to
>> > run BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the
>> > backup.
>> > YOu can also look into SMO object model to incorporate your app to do
>> > the
>> > backup/restore.
>> >
>> > The other option would be to use SQL Server Express' USER INSTANCE, to
>> > which, the user do not have to have local admin rigth to attach
>> > database
>> > to SQL Server Express instance. With USER INSTANCE, you can get the
>> > *.mdf
>> > file easily attached to SQL Server Express at begining of your app and
>> > detached and a backup copy created when your app is done.
>> >
>> > However, be warned, USER INSTANCE is an advanced feature and only
>> > available to SQL Server Express2005/8, and rumor has it that USER
>> > INSTANCE
>> > feature will be dropped from next SQL Server version, because it causes
>> > more trouble (due to the lack of understanding, IMO) than benefit.
>> >
>> > "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
>> > news:u%231F34SgJHA.4868@xxxxxx
>> >> James,
>> >>
>> >> You can always simple use a simple File.Copy for this, (and copy the
>> >> LDF
>> >> file as well)
>> >>
>> >> Set your original database on a for the user accessable place to make
>> >> it
>> >> even easier.
>> >>
>> >> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
>> >>
>> >> Cor
>> >>
>> >>
>> >> "James Page" <JamesPage@xxxxxx> wrote in message
>> >> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
>> >>> Hi all - hope this is the right forum!
>> >>>
>> >>> I have a simple vb.net windows forms application which uses data from
>> >>> an
>> >>> underlying sql express database.
>> >>>
>> >>> It is deployed in a single user environment and the sql express
>> >>> package
>> >>> is
>> >>> installed in the default location.
>> >>>
>> >>> I want to be able to allow the user to backup and restore the
>> >>> underlying
>> >>> .mdf datafile.
>> >>>
>> >>> Can anyone give me a couple of pointers on the best way to achieve
>> >>> this?
>> >>>
>> >>>
>> >>> Many thanks
>> >>>
>> >>
>> >
>>
>>
My System SpecsSystem Spec
Old 01-29-2009   #8 (permalink)
Miro


 
 

Re: Windows forms application and database back-up

Just a thought - from a newbie.

What if you created a function that created a "Select * from Table" for all
tables and wrote that to multiple XML files.
Those XML files is what would be backed up...
Those XML files would be what the menu option would be used to "restore".

Be careful of security though - as to who has access to the folder where
these xml files are created.

I also do not know how big your datafile is / how many records you have.

But that could be a solution for you if you use an .mdf file without
detaching the .mdf file from the server to copy it.

One other thought would be to get something like a 'hosting site' like
www.discountasp.net ( that only comes to mind cause i use that for my dummy
apps )... and keep the data on a hosted site.
A computer failes, install your app on another machine and link to your data
on the hosting site.

Better yet, what if you had a site, with a blank copy of their database
there.
When they want to backup - it pushes the data online to your hosting site
( which is secure ).
-This could be a fee for use / kb or whatever.
When they requrie it, they 'pull' from your server.

The cost would be pretty small ( even at discountasp.net its 10 bux for a
server a month and 10 bux for the hosting = 20 / month ).
Charge 40 and everyone is happy

Miro

"Norman Yuan" <FakeName@xxxxxx> wrote in message
news:eH0LUrhgJHA.5496@xxxxxx
Quote:

>I may read the OP message wrong. But what I said is correct: the *.mdf
>cannot be copied if it is attached to SQL Server/Express. If the OP want to
>use "file copy" to back up the database, he has to detach the database from
>SQL Server/Express first, regardless it is single user or not.
>
> If the OP meant to get *.mdf from somewhere to the said coputer, of course
> it is "File Copy".
>
> "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
> news:uYfhSwdgJHA.1172@xxxxxx
Quote:

>> Norman,
>>
>> Why should it be running in a single user operation?
>>
>> What you write is valid as it is running as multi user source, but as it
>> is single user like the OP wrote, than in my idea simple make copies has
>> the same effect.
>>
>> I was also going for the backup/restore, but rejected that because it has
>> in my idea no advantages in a single user situation.
>>
>> Cor
>>
>>
>> "Norman Yuan" <FakeName@xxxxxx> wrote in message
>> news:ugT5pQXgJHA.4900@xxxxxx
Quote:

>>> If the local SQL Server Express is running (meaning *.mdf/*.ldf is
>>> attached to the SQL Server instance), the files cannot be copied.
>>>
>>> To the OP:
>>>
>>> Depending on how the user logs in to the SQL Server instance, if he/she
>>> has the permission to do the backup/restore, then you can have your app
>>> to run BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the
>>> backup. YOu can also look into SMO object model to incorporate your app
>>> to do the backup/restore.
>>>
>>> The other option would be to use SQL Server Express' USER INSTANCE, to
>>> which, the user do not have to have local admin rigth to attach database
>>> to SQL Server Express instance. With USER INSTANCE, you can get the
>>> *.mdf file easily attached to SQL Server Express at begining of your app
>>> and detached and a backup copy created when your app is done.
>>>
>>> However, be warned, USER INSTANCE is an advanced feature and only
>>> available to SQL Server Express2005/8, and rumor has it that USER
>>> INSTANCE feature will be dropped from next SQL Server version, because
>>> it causes more trouble (due to the lack of understanding, IMO) than
>>> benefit.
>>>
>>> "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
>>> news:u%231F34SgJHA.4868@xxxxxx
>>>> James,
>>>>
>>>> You can always simple use a simple File.Copy for this, (and copy the
>>>> LDF file as well)
>>>>
>>>> Set your original database on a for the user accessable place to make
>>>> it even easier.
>>>>
>>>> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
>>>>
>>>> Cor
>>>>
>>>>
>>>> "James Page" <JamesPage@xxxxxx> wrote in message
>>>> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
>>>>> Hi all - hope this is the right forum!
>>>>>
>>>>> I have a simple vb.net windows forms application which uses data from
>>>>> an
>>>>> underlying sql express database.
>>>>>
>>>>> It is deployed in a single user environment and the sql express
>>>>> package is
>>>>> installed in the default location.
>>>>>
>>>>> I want to be able to allow the user to backup and restore the
>>>>> underlying
>>>>> .mdf datafile.
>>>>>
>>>>> Can anyone give me a couple of pointers on the best way to achieve
>>>>> this?
>>>>>
>>>>>
>>>>> Many thanks
>>>>>
>>>>
>>>
>>
>
My System SpecsSystem Spec
Old 01-30-2009   #9 (permalink)
Cor Ligthert[MVP]


 
 

Re: Windows forms application and database back-up

Miro,

The problem in you suggestion that creating the XML file is normally easy.

But setting it back to the database needs all kind of creation (Make),
insert and maybe relation settings.

Cor

"Miro" <miro@xxxxxx> wrote in message
news:%23jTOSSlgJHA.4200@xxxxxx
Quote:

> Just a thought - from a newbie.
>
> What if you created a function that created a "Select * from Table" for
> all tables and wrote that to multiple XML files.
> Those XML files is what would be backed up...
> Those XML files would be what the menu option would be used to "restore".
>
> Be careful of security though - as to who has access to the folder where
> these xml files are created.
>
> I also do not know how big your datafile is / how many records you have.
>
> But that could be a solution for you if you use an .mdf file without
> detaching the .mdf file from the server to copy it.
>
> One other thought would be to get something like a 'hosting site' like
> www.discountasp.net ( that only comes to mind cause i use that for my
> dummy apps )... and keep the data on a hosted site.
> A computer failes, install your app on another machine and link to your
> data on the hosting site.
>
> Better yet, what if you had a site, with a blank copy of their database
> there.
> When they want to backup - it pushes the data online to your hosting site
> ( which is secure ).
> -This could be a fee for use / kb or whatever.
> When they requrie it, they 'pull' from your server.
>
> The cost would be pretty small ( even at discountasp.net its 10 bux for a
> server a month and 10 bux for the hosting = 20 / month ).
> Charge 40 and everyone is happy
>
> Miro
>
> "Norman Yuan" <FakeName@xxxxxx> wrote in message
> news:eH0LUrhgJHA.5496@xxxxxx
Quote:

>>I may read the OP message wrong. But what I said is correct: the *.mdf
>>cannot be copied if it is attached to SQL Server/Express. If the OP want
>>to use "file copy" to back up the database, he has to detach the database
>>from SQL Server/Express first, regardless it is single user or not.
>>
>> If the OP meant to get *.mdf from somewhere to the said coputer, of
>> course it is "File Copy".
>>
>> "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
>> news:uYfhSwdgJHA.1172@xxxxxx
Quote:

>>> Norman,
>>>
>>> Why should it be running in a single user operation?
>>>
>>> What you write is valid as it is running as multi user source, but as it
>>> is single user like the OP wrote, than in my idea simple make copies has
>>> the same effect.
>>>
>>> I was also going for the backup/restore, but rejected that because it
>>> has in my idea no advantages in a single user situation.
>>>
>>> Cor
>>>
>>>
>>> "Norman Yuan" <FakeName@xxxxxx> wrote in message
>>> news:ugT5pQXgJHA.4900@xxxxxx
>>>> If the local SQL Server Express is running (meaning *.mdf/*.ldf is
>>>> attached to the SQL Server instance), the files cannot be copied.
>>>>
>>>> To the OP:
>>>>
>>>> Depending on how the user logs in to the SQL Server instance, if he/she
>>>> has the permission to do the backup/restore, then you can have your app
>>>> to run BACK DATABASE..../RESTORE DATABASE... TSQL statement to do the
>>>> backup. YOu can also look into SMO object model to incorporate your app
>>>> to do the backup/restore.
>>>>
>>>> The other option would be to use SQL Server Express' USER INSTANCE, to
>>>> which, the user do not have to have local admin rigth to attach
>>>> database to SQL Server Express instance. With USER INSTANCE, you can
>>>> get the *.mdf file easily attached to SQL Server Express at begining of
>>>> your app and detached and a backup copy created when your app is done.
>>>>
>>>> However, be warned, USER INSTANCE is an advanced feature and only
>>>> available to SQL Server Express2005/8, and rumor has it that USER
>>>> INSTANCE feature will be dropped from next SQL Server version, because
>>>> it causes more trouble (due to the lack of understanding, IMO) than
>>>> benefit.
>>>>
>>>> "Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
>>>> news:u%231F34SgJHA.4868@xxxxxx
>>>>> James,
>>>>>
>>>>> You can always simple use a simple File.Copy for this, (and copy the
>>>>> LDF file as well)
>>>>>
>>>>> Set your original database on a for the user accessable place to make
>>>>> it even easier.
>>>>>
>>>>> http://msdn.microsoft.com/en-us/libr...file.copy.aspx
>>>>>
>>>>> Cor
>>>>>
>>>>>
>>>>> "James Page" <JamesPage@xxxxxx> wrote in message
>>>>> news:EDBFF4E5-D8C0-4503-B2CE-664DB5960EEC@xxxxxx
>>>>>> Hi all - hope this is the right forum!
>>>>>>
>>>>>> I have a simple vb.net windows forms application which uses data from
>>>>>> an
>>>>>> underlying sql express database.
>>>>>>
>>>>>> It is deployed in a single user environment and the sql express
>>>>>> package is
>>>>>> installed in the default location.
>>>>>>
>>>>>> I want to be able to allow the user to backup and restore the
>>>>>> underlying
>>>>>> .mdf datafile.
>>>>>>
>>>>>> Can anyone give me a couple of pointers on the best way to achieve
>>>>>> this?
>>>>>>
>>>>>>
>>>>>> Many thanks
>>>>>>
>>>>>
>>>>
>>>
>>
>
My System SpecsSystem Spec
Old 01-30-2009   #10 (permalink)
James Page


 
 

RE: Windows forms application and database back-up

Thanks everyone for your input.

To clarify here is the full picture:

The client buys and sells used vans here in the UK and wants keep a record
of how much he spends on a vehicle and how much he sells them for. Plus he
wants to keep a historical record of all the vehicles that pass through his
business.

Designing the forms application, and the underlying database, is fairly
straightforward, but in the event of a computer failure or change of pc I
wanted a simple way for him to press a button from within the app so that the
underlying database is copied to a location of his choice (usb stick, cd etc).

Once the original application is reinstalled he should be able to click
another button that overwrites the empty database file with the backup that
he created before.
Ideally this needs to be achieved without my intervention.

The design of the application is with VS2008 and is deployed with sql
express, installer 3.1 etc.
It is to be used on a single stand alone pc.

Am I right in thinking that a basic ‘file copy’ / ‘file write’ scenario
cannot be achieved once the application has been deployed or does the
database file only get attached whilst the application is running?
If the latter is true I should be able backup & restore by writing a
standalone application that does not invoke the attachment of the *.mdf/
*.ldf files to sql express – or is my thinking wrong on this?

Looking forward to your thoughts...

Many thanks

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Works database 2007 and Office database 2003 .NET General
simulate continuous forms & subforms in a windows forms application .NET General
How to switch back to Microsoft wireless application from Dell wir Vista networking & sharing
Windows Forms Editor PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46