|
追加数据, 采用微软ADO (ActiveX data object) 数据模型, 分别操纵SQL Server 和Access 数据对象, 追加记录数据来完成, 有以下过程块CopyDa2ta :
Private Sub copyData () Set sourceCn = New adodb. Connection sourceCn. CursorLocation = adUseServer strSql =“PROVIDER = MSDASQL ; dsn = xgsdb ; uid = sa ; pwd = ;” sourceCn. Open strSql Set targetCn = New adodb. Connection targetCn. CursorLocation = adUseClient targetCn. Open ” PROVIDER = Microsoft. Jet. OL Edb. 3.51 ; Data Source = ”& tagFilName &“;” End If //追加新表 For i = 0 To tabN - 1 Set targetRst = New adodb. Recordset strSql = ”select 3 from ”& tabName (i) targetRst. Open strSql , targetCn , adOpenStatic , adLockPes2simistic , adCmdText Set sourceSet = New adodb. Recordset strSql = ”select 3 from ”& tabName (i) & strSQLApp sourceSet. Open strSql , sourceCn zdN = sourceSet. Fields. Count If sourceSet. EOF Then Go To hh sourceSet. MoveFirst Do While Not sourceSet. EOF targetRst. AddNew For j = 0 To zdN - 1 If Trim (sourceSet. Fields (j) . Value) = ””Then targetRst. Fields (j) . Value = Null Else targetRst. Fields (j) . Value = Trim (sourceSet. Fields(j) . Value) End If //复制记录 Next targetRst. Update sourceSet. MoveNext Loop recN = targetRst. RecordCount hh :sourceSet. Close Set sourceSet = Nothing targetRst. Close Set targetRst = Nothing Next targetCn. Close Set targetCn = Nothing sourceCn. Close Set sourceCn = Nothing End Sub //删除链接 |
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页 |