不是的,我想导出数据———— 用object.ExportData( BulkCopy ) 导出数据,object好象只能是表或视图,这样就把整个表导出了,现在如果我想导出该表中的指定的那些记录,所以我在想能不能把记录集转换成表格的? 或者有没有针对记录集的导出方法? 以下是在vb中写的程序: Public Sub Command1_Click() Dim oServer As New SQLDMO.SQLServer Dim oDatabase As New Database Dim oBCP As New SQLDMO.BulkCopy Dim vbComma Dim nRows As Long Dim t As Table oServer.EnableBcp = True oServer.Connect "servername", "user", "password" Set oDatabase = oServer.Databases(Text1.Text) oBCP.ColumnDelimiter = vbComma oBCP.DataFileType = SQLDMODataFile_CommaDelimitedChar oBCP.ImportRowsPerBatch = 1000 oBCP.MaximumErrorsBeforeAbort = 1 oBCP.RowDelimiter = vbCrLf oBCP.ServerBCPDataFileType = SQLDMOBCPDataFile_Char oBCP.UseExistingConnection = True For Each t In oDatabase.Tables If t.Name = Text2.Text Then If t.SystemObject = False Then oBCP.DataFilePath = Text3.Text & "\" & t.Name & ".csv" nRows = t.ExportData(oBCP) MsgBox nRows & " rows exported from " & t.Name End If End If Next oServer.DisConnect oServer.Close End Sub 上面的程序指定了表名t.Name = Text2.Text,现在我想导出该表中的指定记录应当如何实现啊?
我现在是采取了Dance1969(酋长)的方法遇到了新的问题,因为我从一个表中取的一条一条的记录,而save 的时候我想把这些记录一起保存,所以想把这些记录放到另外一个记录集中,然后再save,该怎么实现??? 怎么把一个记录集的记录放入另一个记录集? Dim rs1 As New ADODB.Recordset rstbl.Open "select * from tblname where condition", FCData.Cn, adOpenDynamic, adLockOptimistic, adCmdText 'rs1得到了一条记录 Dim rs2 As New ADODB.Recordset 现在我想把rs1得到的记录放到记录集rs2中去应怎么实现?
用object.ExportData( BulkCopy ) 导出数据,object好象只能是表或视图,这样就把整个表导出了,现在如果我想导出该表中的指定的那些记录,所以我在想能不能把记录集转换成表格的?
或者有没有针对记录集的导出方法?
以下是在vb中写的程序:
Public Sub Command1_Click()
Dim oServer As New SQLDMO.SQLServer
Dim oDatabase As New Database
Dim oBCP As New SQLDMO.BulkCopy
Dim vbComma
Dim nRows As Long
Dim t As Table
oServer.EnableBcp = True
oServer.Connect "servername", "user", "password"
Set oDatabase = oServer.Databases(Text1.Text)
oBCP.ColumnDelimiter = vbComma
oBCP.DataFileType = SQLDMODataFile_CommaDelimitedChar
oBCP.ImportRowsPerBatch = 1000
oBCP.MaximumErrorsBeforeAbort = 1
oBCP.RowDelimiter = vbCrLf
oBCP.ServerBCPDataFileType = SQLDMOBCPDataFile_Char
oBCP.UseExistingConnection = True
For Each t In oDatabase.Tables
If t.Name = Text2.Text Then
If t.SystemObject = False Then
oBCP.DataFilePath = Text3.Text & "\" & t.Name & ".csv"
nRows = t.ExportData(oBCP)
MsgBox nRows & " rows exported from " & t.Name
End If
End If
Next
oServer.DisConnect
oServer.Close
End Sub
上面的程序指定了表名t.Name = Text2.Text,现在我想导出该表中的指定记录应当如何实现啊?
2 定义数据源和数据目标
3 将本地包保存为Visual Basic代码(在位置处选择类型)
4 将自动生成的转换模块代码中的查询语句改为全局变量
5 每一次调用转换代码前,指定数据源的查询语句即可。
可以用ADO的OPEN的方法打开这个文件记录集.
怎么把一个记录集的记录放入另一个记录集?
Dim rs1 As New ADODB.Recordset
rstbl.Open "select * from tblname where condition", FCData.Cn, adOpenDynamic, adLockOptimistic, adCmdText
'rs1得到了一条记录
Dim rs2 As New ADODB.Recordset
现在我想把rs1得到的记录放到记录集rs2中去应怎么实现?