数据导出处理办法, 有没有更好的方法?

h2high 2003-11-28 02:48:25
从SAP系统中导出数据到SQL中,现在只能一条一条的Insert,大家有没有其它方法?
代码如下:

----------------------------------------------------------------

Set conn = New ADODB.Connection
conn.Open "provider=sqloledb;server=192.168.10.1;uid=web;pwd=web;database=website"
If oConnection Is Nothing Then
'MsgBox "Ready to Logon Now..."
Set SAPLogonControl1 = CreateObject("SAP.LogonControl.1")'SAP登录
Set oConnection = SAPLogonControl1.NewConnection
oConnection.Client = "500"
oConnection.User = "web"
oConnection.Password = "web"
oConnection.ApplicationServer = "192.168.10.6"
oConnection.SystemNumber = "00"
LogonInfo = oConnection.Logon(wac.hWnd, True)
End If
If oConnection.IsConnected <> tloRfcConnected Then
mystring = "系统无法登陆!"
mytextfile.writeline (mystring)
mytextfile.writeblanklines (1)
mytextfile.Close
Unload Me
Exit Sub
End If

'***************

Rem Create Functions Object
Set SAPFunction = CreateObject("SAP.Functions")'SAP BAPI 调用
Set SAPFunction.Connection = oConnection


Set oFunc = SAPFunction.Add("BAPI_SALES_ORDERS")
If Not oFunc.Call Then
Exit Sub
End If

'*********************************

sql = "delete from salesinfo"
conn.Execute (sql)

For i = 1 To oFunc.Tables("TSALESINFO").RowCount
sql = "insert into salesinfo values('" & oFunc.Tables("TSALESINFO")(i, "VBELN") & "'," & oFunc.Tables("TSALESINFO")(i, "POSNR") & ",'" & oFunc.Tables("TSALESINFO")(i, "AUDAT") & "','" & oFunc.Tables("TSALESINFO")(i, "BSTNK") & "', " & _
"'" & oFunc.Tables("TSALESINFO")(i, "MATNR") & "'," & oFunc.Tables("TSALESINFO")(i, "KWMENG") & ",'" & oFunc.Tables("TSALESINFO")(i, "VRKME") & "','" & oFunc.Tables("TSALESINFO")(i, "LFGSA") & "'," & _
" " & oFunc.Tables("TSALESINFO")(i, "NETPR") & "," & oFunc.Tables("TSALESINFO")(i, "NETWR") & ",'" & oFunc.Tables("TSALESINFO")(i, "WAERK") & "','" & oFunc.Tables("TSALESINFO")(i, "VSTEL") & "'," & _
"'" & oFunc.Tables("TSALESINFO")(i, "ROUTE") & "','" & oFunc.Tables("TSALESINFO")(i, "WERKS") & "','" & oFunc.Tables("TSALESINFO")(i, "ZTERM") & "','" & oFunc.Tables("TSALESINFO")(i, "INCO1") & "'," & _
"'" & oFunc.Tables("TSALESINFO")(i, "INCO2") & "','" & oFunc.Tables("TSALESINFO")(i, "KNKLI") & "','" & oFunc.Tables("TSALESINFO")(i, "KUNAG") & "','" & oFunc.Tables("TSALESINFO")(i, "KUNWE") & "','" & oFunc.Tables("TSALESINFO")(i, "SDABW") & "')"

' Debug.Print sql

conn.Execute (sql)
Next

----------------------------------------------------------------
把sql串起来再 conn.execute(sql)的不算, 大家有没有其它更好的办法?
...全文
60 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mingtian2008 2003-12-02
  • 打赏
  • 举报
回复
up
h2high 2003-12-02
  • 打赏
  • 举报
回复
没有人知道吗?

最后一顶!!!!

:(
h2high 2003-12-01
  • 打赏
  • 举报
回复
to: JoAiron(zozo)

我是做个工具把数据导到WEB数据库里面,而且SAP数据库不能直接用用户名/密码登录的.要用到SAP用户登录,同时还有一定的业务逻辑.所以用BAPI在取数.
h2high 2003-12-01
  • 打赏
  • 举报
回复
有人知道吗?
h2high 2003-11-28
  • 打赏
  • 举报
回复
to:online(龙卷风(白学了,重新充电中))
可是怎么能用DTS呢?
只有一端用SQL,另外一边要用组件登录到SAP系统中,不能直接访问他的数据库的.
JoAiron 2003-11-28
  • 打赏
  • 举报
回复
导出数据库表中的内容么?
不是用exp就可以了么?

在dos下键入
exp 用户名/密码@TNS SERVER NAME file=t1.dat full=y
online 2003-11-28
  • 打赏
  • 举报
回复
可以使用sqlserver中的dts功能
很方便的

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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