Project summary [4] - Data backup articles

zhaozj2021-02-16  59

Just use VB.NET development project, a lot of detours in the process of using VB.Net. I hope that my experience can bring some help. [If you need code, you can leave Email, everyone exchange experience]

Project Summary [4] - Database Backup This section considers that using SQL Server to do a backup example, if you use SQLServer to do data backup, many people make such a problem ?? SQLServer General data backup can only be backed up on the server machine In the case, how does the client stay in the local? How to answer this question. The theoretical method is as follows. Backup mode [Internet or LAN] 1. Use SQLServer to do a backup file in the server 2. Turn this backup Files are placed in the IIS directory [must ensure that the server has web way access] 3. Use Explorer to directly download file directly in the client or use the file flow mode to read the file to the local machine

II. Backup mode 2 1. Use SQLServer to use SQL Server to do a good job in the server 2. Use the file stream to read the file to the local machine [LAN] or use the WebServer mode to read the file to the local machine [Internet or LAN]

III. Backup mode three [Internet or LAN] 1. You can use the SQLServer task function to complete the backup method one backup mode two step 1.2. 2. You can use the front two methods to do it.

IV. Backup mode 4 [Internet or LAN] 1. Use the steps above three ways to complete 2. Read the backup file into one of the SQL Server in the SQL Server, read the data, write the file to the client.

All four programs, I have done a probably process analysis, and the above methods are feasible.

Example, due to time, I didn't write four ways of code, I can test it myself] I only made a detailed explanation of the first way 'Windbackup is a class defined by my own, only stored procedures back up a data. DIM Mybackup AS Winbackup.backup = New Winbackup.backup ("MyDatabase", "SA", "SA") 'Performs Backup Function Dim Result As Boolean = Mybackup.BackupDatabase ("MyDatabase", "C: //MyDatabase.dat" If the backup is successful, then the following operation if result = true kiln, where is one of the classes, the purpose is to find the physical path of the IIS service DIM Myiis as Iismanager = new iiismanager () Myiis.connect () 'Direct call shell method To make a file Copy Dim strbackup as string = "xcopy c: //mydatabase.dat" myis.iispath "/mydatabase.dat/-y" DIM I as integer = shell (strbackup, appwinstyle.minimizednofocus, true) ' how to download did not elaborate here, I believe you should know how to use 'http: //servername/myDataBase.dat End If' attached windBackUp IISManager principal function reference Public class IISManager Protected rootfolder As System.DirectoryServices.DirectoryEntry Public Sub New ( ) 'By default, LocalHost is used, that is, accessed the local machine_server = "localhost" _website = "1" _batchflag = False End Sub 'New Public Overloads Sub Connect () ConnectToServer () End Sub' Connect '/

' / private method '/ ' Connection Server Private Sub ConnectToServer () Dim strPath As string = "IIS: //" _server "/ w3svc /" _Website "/ root" try me.rootfolder = new directoryentry "_virdirs =

Getvirdirs (Me.Rootfolder.children) Catch E AS Exception Throw new Exception ("Can't Connect to the Server [" _Server "] ...", E) End Try End Sub 'ConnectToServer' /

' / Get the physical path where the server is located '/ ' / IIS Physical Path Public Function Iispath () AS String Return Rootfolder.properties ("Path"). Value.toString () End Function 'IISPATH' This class uses C # written ... namespace winbackup /// /// primary test /// /// Database name / // Database User Name /// Database password public backup (string databaseuser, string databasepass) {// / / TODO: Add Constructor Logic // String SQL = "Data Source = LocalHost; Initial Catalog =" DatabaseName "; Password =" DatabasePass "; Persist Security Info = true; user ID =" DatabaseUser "; WorkStation ID = TOPS03496; Packet size = 4096 "; // Note that the default database does not and recovered the same name init (SQL);}

///

/// Backup Database /// /// To backed up data source name /// Backup database file name and path /// Public Bool BackupDatabase (String DatabaseName, String Backuptodatabase) {....... // Back up the database to the specified database file ( full backup) sql = "bACKUP DATABASE" databasename "TO" databasename "WITH INIT"; SqlCommand sqlcmd3 = new SqlCommand (sql, conn); sqlcmd3.CommandType = CommandType.Text; try {sqlcmd3.ExecuteNonQuery (); } CatCH (Exception Err) {string str = err.Message; conn.close (); return false;} .....}

Project summary - Start form articles http://expert.9cbs.net/expert/topicview1.asp?id=2513452 item summary [2] - Menu articles http://expert.9cbs.net/Expert/topicView1. ASP? ID = 2557044 Project Summary [3] - Talking about the formal value of the form, and provides an example http://expert.9cbs.net/expert/topicView1.asp?id=2523412

转载请注明原文地址:https://www.9cbs.com/read-23005.html

New Post(0)