Click here to Skip to main content
15,889,482 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to backup an SQL Server database, my question is if I backup with vb net and SQL Server mechanish when I want to "view" and connect to the database with restore do I have to register the database again in SQL (attach) Server? or can I just "pull" the data from file (like an xml eg.)
Posted
Comments
_Asif_ 19-Jun-15 2:59am    
Can you please elaborate a bit more?
Arkadeep De 19-Jun-15 3:09am    
are you saying about backing up the users of database at the time of backup??? if it so, then don't worry you don't need to register that user again, it will automatically create the users for db...If not then elaborate your question..
Member 3892343 20-Jun-15 10:43am    
I mean to reopen the restored database and the original exists but with inserted NEW records, eg database northwin 100 records, backup northwind 100 records, now database northwind 250 records, I want to restore and open with vb the northwind 100 records backup, is it possible only from code vb net?

1 solution

Have a look at this: Backing up an SQL Database in C#[^] - the code is in C#, but it's preety obvious, and the VB is almost identical (there are online converters which may help you: http://converter.telerik.com/[^] for example)

It gives the code I use for backup and restore of SQL databases, and explains the potential problems.
 
Share this answer
 
Comments
Member 3892343 20-Jun-15 10:48am    
so if I am right the 2 databases wil co exist in SQL Server? and I will open only the backup? or can I rename the backup database so to know which to open? that was my question to open the earlier database (backup) when I need it eg records of a period of months january to march backup from the original database delete the records of these month and add next period of months, I want to open the backup database (period january-march) and do changes or just view or print (with vb net), I ask because in regular operation SQL Server doesn't allow 2 same name databases.
OriginalGriff 20-Jun-15 11:12am    
You do not normally have backups online (and if you have any experience, not on the same machine, preferably not in the same building - heck a different country is a good idea).
What you are talking about is archiving, and they should not have the same name: I'd have archives named based on the original DB name and period they cover.
Member 3892343 20-Jun-15 15:50pm    
ok can I archive the database to USB stick and view it from there on the same machine (pc) as the SQL Server main database oe a diffetent pc and then remove the USB stick? What I eant is to have database archived as you said in a removable medium (dvd etc.) and can open it in an same version SQL Server indipendemtly? Thank you anyway for the guide.
OriginalGriff 21-Jun-15 2:25am    
Yes - you can use the ATTACH command:
https://msdn.microsoft.com/en-us/library/ms190794.aspx

But you may get errors trying to attach a database on a read-only medium such as DVD - I haven't tried, but I can see SQL getting rather irritable if it can't write to the MDB and LDB files.
Member 3892343 21-Jun-15 10:58am    
thank you originalgriff I will save to a usb flash stick

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900