SQL Server helps document addresses, direct input in IE MK: @MsitStore: c: /program files/microsoft SQL Server/80/Tools/Books/tsqlref.chm :: / ts_ba-bz_35ww.htm
Backup Database to Disk Path Backup Restore Database from Disk Path Restore Using System.collections; Using System.Security.cryptography;
Using system.data; using system.data.sqlclient; using system.Web;
Using system.Web.SessionState; use system.web.ui.webcontrols; using system.Web.ui.htmlControls;
Using system.diagnost; using system.componentmodel; using system.configuration; using system.data.oledb;
Namespace DBService {/// /// DBOPER class, mainly to backup and recovery of Microsoft SQL Server database //// summary> Public Sealed Class Dboper {/// /// DBOPER class Constructor /// summary> // private dboper () // {//}
/// /// database backup /// summary> /// public static string BackFileName = System.Web.HttpContext.Current.Request.PhysicalApplicationPath "BackUp // MyDbBack.bak"; public static void DbBackup (string DbNanme, string userid, string pwd) {try {SQLDMO.Backup oBackup = new SQLDMO.BackupClass (); SQLDMO.SQLServer oSQLServer = new SQLDMO.SQLServerClass (); oSQLServer.LoginSecure = false; oSQLServer.Connect ( "localhost" , userid, pwd); oBackup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database; oBackup.Database = DbNanme; oBackup.Files = BackFileName; oBackup.BackupSetName = DbNanme; oBackup.BackupSetDescription = "database backup"; oBackup.Initialize = true; oBackup . Sqlbackup (OSQLServer);} catch {throw;}}
/// /// restore database function /// summary> /// Database name param> /// database backup file the full pathname param> /// returns> public bool RestoreDB (string strDbName, string strFileName, string userid, string pwd) {// PBar = pgbMain; SQLDMO.SQLServer svr = new SQLDMO.SQLServerClass (); Try {// server name, database username, database username password Svr.connect ("localhost", userid, pwd); sqldmo.queryresults = svr.enumprocesses (-1); int icolpidnum = -1; INT iCOLDBNAME = -1; for (int i = 1; i
}