为什么用SQLDMO.BulkCopy导出的数据集为empty?

szsammy 2003-08-22 05:38:04
请高手指教!

我在ASP中的代码如下:

Set objBCP=Server.CreateObject("SQLDMO.BulkCopy")
Set objDB =objServer.Databases("aaa")

objServer.EnableBcp = True

With objBCP
.ColumnDelimiter = vbTab
.DataFileType = SQLDMODataFile_TabDelimitedChar
.ImportRowsPerBatch = 1000
.MaximumErrorsBeforeAbort = 1
.RowDelimiter = vbCrLf
.ServerBCPDataFileType = SQLDMOBCPDataFile_Char
.UseExistingConnection = True
End With

If Not objDB_bak.DBOption.SelectIntoBulkCopy Then
objDB_bak.DBOption.SelectIntoBulkCopy = True
End If
table="data"
objBCP.DataFilePath ="c:\temp\"&table&".txt"

tmpRows = objDB.Tables(table).ExportData(objBCP) '在此得到的tmpRows总是empty,不知道为什么??

If (tmpRows > 0) Then
'此处继续......
......
...全文
48 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yonghengdizhen 2003-08-28
  • 打赏
  • 举报
回复
我还有问题就是,你说的这一句可以在程序里用吗?
bcp "SELECT au_fname, au_lname FROM pubs..authors ORDER BY au_lname" queryout Authors.txt -c -Sservername -Usa -Ppassword
这个必须通过存储过程调用外部程序.
或者直接用wsh调用


szsammy 2003-08-25
  • 打赏
  • 举报
回复
UP
szsammy 2003-08-25
  • 打赏
  • 举报
回复
请高手帮帮忙看一下吧
szsammy 2003-08-23
  • 打赏
  • 举报
回复
samuelpan(欧乐)

我的问题是在
objDB.Tables(Table).ImportData objBCP
这一句的地方结果集总是empty,不知道为什么?
samuelpan 2003-08-23
  • 打赏
  • 举报
回复
Public Function BCP(ByVal Server As String, ByVal UserName As _

String, ByVal Password As String, ByVal Database As String, _

ByVal Table As String, ByVal FileName As String, _

Optional Import As Boolean) As Boolean

Dim objServer As New SQLDMO.SQLServer
Dim objBCP As New SQLDMO.BulkCopy
Dim objDB As SQLDMO.Database

If Import = True And Dir(FileName) = "" Then Exit Function

On Error GoTo ErrorHandler

objServer.Connect Server, UserName, Password
objServer.EnableBcp = True


Set objDB = objServer.Databases(Database)

With objBCP
.DataFilePath = FileName
'Below speeds things up
'but does not log the bulk copy operation
'comment out if this is not what you
'desire
.UseBulkCopyOption = True
End With

If Import Then
objDB.Tables(Table).ImportData objBCP
Else
objDB.Tables(Table).ExportData objBCP
End If

BCP = True

ErrorHandler:
Set objBCP = Nothing
Set objServer = Nothing
End Function

szsammy 2003-08-23
  • 打赏
  • 举报
回复
没有人知道吗?555555555

分不够可以再加
szsammy 2003-08-23
  • 打赏
  • 举报
回复
不知道哪里有问题,请指教.
kfcn 2003-08-22
  • 打赏
  • 举报
回复
确定语句正确?

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧