2uzhan.com
Advertisement
Now Place:2uzhan.com » Restoring database programmatically

Restoring database programmatically

Database @ November 15, 2004   Views:0

I have an application, written in MFC C++, that on occassion requires restoration from a backup file. Backup files are generated automatically on a daily basis. This database in more of a temporary storage facility than it is to continually collect new data. On occassion the previous days data is needed to complete the days tasks.

This was originally written to use MS Access for database support. It has now been converted to run in SQL Server.

In MS Access, the backup procedure consisted of copying the mdb file to a specified target filename and folder. There was never a programatic way to restore the previous days database, requiring a call into customer service, walking a non-programmer/non-administrator through restoring the DB manually in Access.

Using SQL Server, I would like to take advantage of a stored procedure call to both backup and restore the database. I have successfully created a stored proc for backing up, and got some sample code off of one of the forums for attempting to restore. The problem is understanding the proper procedure for logging out any and all non-owner type users, as I am being locked out to do this programically. I can restore from SQL Enterprise Manager with no problems, with all of the users I have logged on (in other words, not doing anything special to first log off anybody). It appears that Enterprise Manager has a way of suspending the logged in users temporarily to allow a restoration.

I am an experienced C++ programmer, and have a year or so of SQL Server behind me. What I have not had to study is log in/administrative techniques such as the one desribed above. I have 4 books on their way to dive into this, as well as the online documentation. I have searched code guru extensively for this answer, and have gotten close.

Can anyone provide some quick reading, or a solution? Has anyone written a stored procedure that will perform the same duties that Enterprise Manager does for a restoration?

Thanks - Jim

--------------Solutions-------------

Yeah I have written program to restore from VC++ using

Load database abc from disk = filename

But restoring does require exclusive access to database.

I am not sure I understand your problem very well, but i might can suggest something If I knwo what exact is the problem here as am still working on backing up to and restorin from zip files using VC++ and SQL Server.

Tags:
© 2018 2uzhan.com Contact