扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:杨梅娟 陈亚军 来源:计算机与信息技术 2007年10月14日
关键字:
在本页阅读全文(共2页)
Private Sub copyStru () Set dbsTemp = wrkjet. OpenDatabase (tagFilName)// 链接表的过程 For i = 0 To tabN - 1 Set tdfLinked = dbsTemp. CreateTableDef (“linkTab”) tdfLinked. Connect = “OdbC; DATABASE = xgsbgsys ; UID = sa ; PWD = ; DSN = xgsdb ;” tdfLinked. SourceTableName = tabName (i) dbsTemp. TableDefs. Append tdfLinked Set temp Tab = dbsTemp. CreateTableDef () temp Tab. Name = tabName (i) //创建新表的过程 For Each fld In tdfLinked. Fields Set newFil = temp Tab. CreateField (fld. Name , fld. Type ,fld. Size) newFil. OrdinalPosition = fld. OrdinalPosition newFil. Required = fld. Required temp Tab. Fields. Append newFil Next //创建索引 For Each idx In tdfLinked. Indexes Set newIdx = temp Tab. CreateIndex () With newIdx Name = tabName (i) & ” x” Fields = idx. Fields Unique = idx. Unique Primary = idx. Primary End With temp Tab. Indexes. Append newIdx Next dbsTemp. TableDefs. Append temp Tab Set temp Tab = Nothing dbsTemp. TableDefs. Delete ”linkTab” Next i dbsTemp. Close Set dbsTemp = Nothing wrkjet. Close Set wrkjet = Nothing End Sub End Sub |
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 //删除链接 |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者