如何将不同服务器上面的不同类型数据库合并
请各位大虾指点一下小弟:以下是我写的一个将vfp数据添加到sql server的程序:
Sub main()
Const sSQLServerName As String = "sqlsrv" '服务器名称或地址
Const sSQLDBUserName As String = "sa" '数据库帐号
Const sSQLDBPassword As String = "sqlpw" '数据库密码
Const sSQLDBName As String = "mysqldb" '数据库名称
Const sSqlTable As String = "mysqldb.dbo.test_table" ' 需要使用的数据表
Const sDbfDir As String = "\\sqlsrv\F$\dbfpath" ' dbf文件存放目录
Const sDbfFile As String = "mydbf" ' dbf文件名
Dim connDataBase As ADODB.Connection
Dim sSqlString As String
Dim c As
Dim lRecordCount As Long
Set connDataBase = New ADODB.Connection
connDataBase.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=" & sSQLServerName & ";User ID=" & sSQLDBUserName & ";Password=" & sSQLDBPassword & ";Database=" & sSQLDBName & ";"
connDataBase.CursorLocation = adUseClient
= 0
connDataBase.Open
sSqlString = "insert into " & sSqlTable & " (field1, field2) select field1, field2 from openrowset('MSDASQL.1', 'DRIVER=Microsoft Visual Foxpro Driver;SourceType=DBF;SourceDB=" & sDbfDir & "', 'select * from " & sDbfFile & ".dbf')"
Set c = New
Set c.ActiveConnection = connDataBase
= adCmdText
= sSqlString
c.Execute lRecordCount
Set c = Nothing
connDataBase.Close
Set connDataBase = Nothing
End Sub
现问题是:
如果将dbf和sqlserver放在不同的服务器上面的话, 例如将上面sDbfDir的值改为"\\dbfsrv\F$\dbfpath", 则程序出错, 如何修改, 请赐教, 谢谢!