pat562456


Hi All,

I added a demo page for all of the databinding controls in .NET (GridView, DetailsView, etc). In some of these controls I'm allowing the user to insert/update and delete.

Can anyone suggest a good and relativley uncomplicated way to roll the db back after the user is done 'messing' around

Thanks!

Pat




Re: Rollback for a demo database table

zuomin


Since this is just a small demo app.

The bast way to clean the mess database is just to drop and recreate all. Normally this can be done in a single script.

There is a rollback transaction option. But it's not quite fit in this case.

Because when user insert a record in one transaction. and not commit it. it's not allowed to do a second insert on the same table. It doesn't make sense for a demo.


Thanks,

Zuomin





Re: Rollback for a demo database table

pat

Can you point me in the right direction I'm using SQL Server and know how to create scripts - but I thought scripts only re-create the table structure, not re-populate with data also. Is this possible If so, how

Thanks

Pat






Re: Rollback for a demo database table

zuomin

You can also use backup and restore database.

Something like:

USE master;

BACKUP DATABASE pubs TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\pubs.bak';

RESTORE DATABASE pubs FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\pubs.bak';

The reason I use the default backup database path is, if your SQL Server service is running under NetworkService account,

by default it can't write to other place of file system. OR you have to set the ACL. Use the default backup path may just fit your needs.

Please also make sure replace with your database instance path.


Thanks,

Zuomin







Re: Rollback for a demo database table

Ben Miller

You could use this utility to generate the INSERT statements for recreating your data in the tables.

http://www.sqlscripter.com/






Re: Rollback for a demo database table

pat

I'm thinking this:

USE master;

BACKUP DATABASE pubs TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\pubs.bak';

RESTORE DATABASE pubs FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\pubs.bak';


is something that's done in SQL Server Manager using Execute Query.

I'm curious if this can be done programatically from the GAC using code blocks in Session_Start and Session_End.

If so could someone point me in the right direction as far as what that statement would be

Would I use SqlConnection and SqlDataAdaptor objects with the above statements as arguments

Thanks!

Pat