且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数据从远程SQL Server复制到本地访问数据库

更新时间:2022-11-25 11:26:53

如果它是Microsoft SQL Server(写为我们的中间SQL Server"),则***的方法是使用数据.

请参阅复制概述的类型 [
If it is Microsoft SQL Server ( as written "our central SQL server" ), the best way is to use replication of data.

See Types of Replication Overview[^] with MS SQL Server.

It is very reliable way to distribute SQL data over many locations.


Try
            
            Dim sDBFile As String = "SERVER PATH"
            Dim sBackUpFile As String = "D:\BACKUP"
            If Not System.IO.Directory.Exists(sBackUpFile) Then
                System.IO.Directory.CreateDirectory(sBackUpFile)
            End If
            '  a = Format


(Now.Date,"ddMMyyyyy")跨度> b = a c1 = Now.ToLongTimeString d = c1 c1 = c1.Replace(" " ") c1 = c1.Replace(" " ") d = c1 sBackUpFile& = " ' 首先检查您要压缩的文件是否存在 如果 File.Exists(sDBFile)然后 Dim db As 新建 OleDb.OleDbConnection ' CompactDatabase有两个参数,在目标路径上创建紧凑型数据库的副本 FileCopy(sDBFile,sBackUpFile) 结束 如果 ' 从压缩文件中还原原始文件 如果 File.Exists(sBackUpFile)然后 File.Delete(sBackUpFile) File.Copy(sDBFile,sBackUpFile,) 结束 如果 捕获,例如 As 异常 MsgBox(例如消息) 结束 尝试 MsgBox(" & vbCrLf& 此备份可以在D:\ BACKUP \ ABC_today'sdate.mdb",MsgBoxStyle.Information + MsgBoxStyle.OkOnly中找到, )
(Now.Date, "ddMMyyyy") b = a c1 = Now.ToLongTimeString d = c1 c1 = c1.Replace(":", "") c1 = c1.Replace(" ", "") d = c1 sBackUpFile &= "\ABC.mdb" 'First check the file u want to compact exists or not If File.Exists(sDBFile) Then Dim db As New OleDb.OleDbConnection 'CompactDatabase has two parameters, creates a copy of compact DB at the Destination path FileCopy(sDBFile, sBackUpFile) End If 'restore the original file from the compacted file If File.Exists(sBackUpFile) Then File.Delete(sBackUpFile) File.Copy(sDBFile, sBackUpFile, True) End If Catch ex As Exception MsgBox(ex.Message) End Try MsgBox("Backup of INTELPAT database was backedUp successfully !" & vbCrLf & "This Backup can bi found in D:\BACKUP\ABC_today'sdate.mdb ", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, )




这段代码将复制整个数据库....:)




This code will copy entire database....:)