首先,连接sybase的数据库 http://wlbookwl.myrice.com/jck/1027sybase.htm然后这样插入数据 cn.Execute "insert into openrowset('Microsoft.Jet.OLEDB.4.0','e:\db1.mdb';'admin';'',t_order) select * from t_order"
我要的是将数据从excel导入到sybase里面。大家帮看看啊。
如果excel中的数据规范,字段数又不多,可以这样做: dim aa() as string Dim excel_app As Object Dim excel_sheet As Object Set excel_app = CreateObject("excel.application") 'excel对象 Set excel_app = New Excel.Application excel_app.Workbooks.Open FileName:="\111.xls" If Val(excel_app.Application.Version) >= 8 Then '检查excel文件的版本 Set excel_sheet = excel_app.ActiveSheet
Else Set excel_sheet = excel_app End If比如excel中有两列: redim aa(1 to 2) '''按行读excel表 do aa(1)=excel_sheet.cells(i,1) ''第一列 aa(2)=excel_sheet.cells(i,2) ''第二列 strsql="insert into tablenaem values('" & aa(1) & "','" & aa(2) & "')" pubconnect.Execute strsql If Len(aa(1)) = 0 And Len(aa(2)) = 0 Then Exit Do ''如果此行为空,退出循环 i=i+1 loop
提示application_defined or object_defined error.工程定义错误或者目标定义错误??
http://wlbookwl.myrice.com/jck/1027sybase.htm然后这样插入数据
cn.Execute "insert into openrowset('Microsoft.Jet.OLEDB.4.0','e:\db1.mdb';'admin';'',t_order) select * from t_order"
dim aa() as string
Dim excel_app As Object
Dim excel_sheet As Object
Set excel_app = CreateObject("excel.application") 'excel对象
Set excel_app = New Excel.Application
excel_app.Workbooks.Open FileName:="\111.xls"
If Val(excel_app.Application.Version) >= 8 Then '检查excel文件的版本
Set excel_sheet = excel_app.ActiveSheet
Else
Set excel_sheet = excel_app
End If比如excel中有两列:
redim aa(1 to 2)
'''按行读excel表
do
aa(1)=excel_sheet.cells(i,1) ''第一列
aa(2)=excel_sheet.cells(i,2) ''第二列
strsql="insert into tablenaem values('" & aa(1) & "','" & aa(2) & "')"
pubconnect.Execute strsql
If Len(aa(1)) = 0 And Len(aa(2)) = 0 Then Exit Do ''如果此行为空,退出循环
i=i+1
loop