|
-
Feb 21st, 2013, 07:15 AM
#1
Thread Starter
Fanatic Member
Backup of SQl
Hi
How we can take a Backup of SQL Express Database using Visual Basic as Front-End . I want to give user an option to take Backup.
Thanks
-
Feb 21st, 2013, 07:32 AM
#2
-
Feb 21st, 2013, 07:49 AM
#3
Re: Backup of SQl
 Originally Posted by SamOscarBrown
Can you use filecopy?
On an SQL Express Database?
I'd rather do an SQL-Dump into a Textfile (csv) per Table and be done with it.
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Feb 21st, 2013, 10:16 AM
#4
Re: Backup of SQl
Probably......that is why I said "Can?" "-) Just downloaded SQL Express yesterday, and plan to start learning to use it with VB6....didn't realize the database was like ORACLE's, where a dump IS the best option. Lo Siento.
-
Feb 21st, 2013, 10:52 AM
#5
Re: Backup of SQl
Hi,
Have a look at a previous post of mine on another forum. This is in .NET but I am sure you can accommodate this example in VB6:-
http://www.vb dot net forums .com/mysql/53335-code-backup-restore.html
NB. Remove the spaces in the link since this forum does not allow linking to the forum I am trying to direct you to??????
Cheers,
Ian
Last edited by IanRyder; Feb 21st, 2013 at 11:07 AM.
Reason: Link Not Accepted??
-
Feb 21st, 2013, 12:31 PM
#6
Re: Backup of SQl
Thread moved to the 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)
 Originally Posted by IanRyder
NB. Remove the spaces in the link since this forum does not allow linking to the forum I am trying to direct you to??????
A site with a very similar name (without the S) spammed us quite a bit at some point, so their name was added to our filtering system - which unfortunately causes this one to be partially masked too.
-
Feb 21st, 2013, 01:10 PM
#7
Frenzied Member
Re: Backup of SQl
WHy not just write a Stored Proc to backup your database (tons of references on the web on how to do this), and then call the procedure from you VB application?
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Feb 22nd, 2013, 12:23 AM
#8
Re: Backup of SQl
Thanks si_the_geek - that explains a lot.
Cheers,
Ian
-
Feb 22nd, 2013, 08:23 AM
#9
Re: Backup of SQl
 Originally Posted by SamOscarBrown
Can you use filecopy?
Eww! No... would not recommend that... 1) takes up a lot of space, 2) you would have to copy both the mdf and the ldf files... see #1, 3) The files are live and you run the risk of corrupting the database... in the amount of time it takes to copy the mdf, the ldf will (may) be getting updated... now the two are out of sync.
 Originally Posted by Zvoni
On an SQL Express Database?
I'd rather do an SQL-Dump into a Textfile (csv) per Table and be done with it.
That's almost worse than doing a filecopy. I know it's the way MySQL works, but I don't like it and it takes an exorbitant amount of time to run, and don't forget point 1 & 3 above...
 Originally Posted by SeanGrebey
WHy not just write a Stored Proc to backup your database (tons of references on the web on how to do this), and then call the procedure from you VB application?
That's the sanest thing I've heard... although I wouldn't do it in a stored proc... just issue the commands directly from the app... it's easiest and fasted way to ensure that the backup is complete and proper.
-tg
-
Feb 23rd, 2013, 03:55 AM
#10
Thread Starter
Fanatic Member
Re: Backup of SQl
Hi
Can u tell me some links
Thanks
-
Feb 23rd, 2013, 08:46 AM
#11
Re: Backup of SQl
This is the T-SQL command used in MS SQL to backup a database
Code:
BACKUP DATABASE DocTest TO DISK = 'D:\some folder\DocTest_20130223.bak'
Note - while this is fine to execute against a MS SQL Express type of database - DO NOT DO this against a production SQL SERVER running a NON-EXPRESS version. If that SERVER is already running maintenance plans for doing backup you should use the MAINTENANCE PLAN to run a ONE-OFF backup.
-
Feb 23rd, 2013, 09:42 AM
#12
Lively Member
Re: Backup of SQl
You could shell out to a command line to export the required tables, using sqlcmd or bcp -
http://stackoverflow.com/questions/4...r-using-sqlcmd
-
Feb 23rd, 2013, 10:13 AM
#13
Re: Backup of SQl
Why are we talking about EXPORTING tables and making TEXT FILES here?
MS SQL SERVER - a "multi" physical file database system (has both MDF and also LDF files - data and log portions) - should only EVER be backed up with the T-SQL BACKUP statement.
This is executed just like any other SQL statement - using a regular command object.
It can be done regardless of whether the client is on the same "workstation" as the DB itself - so it's network appropriate.
-
Feb 23rd, 2013, 01:33 PM
#14
Lively Member
Re: Backup of SQl
There's "ideal and proper", and then there's "what's good enough and what he wants to do for his own reasons"
-
Feb 23rd, 2013, 01:49 PM
#15
Re: Backup of SQl
It is really important to realize that TG mentioned a point that is key here. Let me elaborate...
Changes made to a MS SQL SERVER database are first PLACED in the LOG file.
The LOG does NOT ONLY contain UNCOMMITTED data - but also COMMITTED data that the lazy-time algorithms have not yet written back to the MDF file.
That means when you run a select from the DATABASE there is a chance that data comes from both the MDF and LDF physical files.
So a FILE COPY of the MDF or LDF is kind of unsafe - as you could imagine the timing of these physical disk copies will never correlate with the state of the MDF and LDF files as it is managed by the DATABASE ENGINE.
The BACKUP command I show is a command handed off to the DATABASE ENGINE to do a CLEAN BACKUP of both the MDF and LDF files. These two files are placed into a single .BAK file - usually much, much smaller then the actual MDF and LDF files which have tons of allocated disk spaced used for database reasons. Single file that can be RESTORED and guaranteed to be a real copy of the DB at the POINT IN TIME it was run.
If this is a single user SQL SERVER EXPRESS type of setup then a file copy could be done - but that's a bad habit to get into and doesn't actually, in my opinion, take less time or code to accomplish.
-
Feb 25th, 2013, 08:33 AM
#16
Re: Backup of SQl
I agree with SzLamany and Techgnome.
1. A backup is the correct mechanism provided by the DB engine. It's guarenteed to give the expected resut.
2. It's trivial to carry out. Considerably easier than a filecopy, for example, which will require the additional actions to take the database off line before the OS will allow you access. And MUCH easier than trying to copy the data table by table (which will lose all your metadata).
Trying to do a filecopy in these circumstances is like going to a restaurant and insisting they serve your soup in the collander you brought with you instead of the bowl they were happy to provide.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|