OpenRowSet Excel 数据批量插入 SQL server 问题
Public Sub insertToDb()'----------------------------
' 插入到数据库
' owen
' 2008/03/18
'----------------------------
Dim conn As New ADODB.Connection
Dim cmd As New
Dim strConn As String
Dim strCmdSql As String
conn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_YDSH;Data Source=192.168.30.150;password=qaz123edc456tgb"
strCmdSql = "insert into tb_CodeTemp SELECT * FROM OpenRowSet('Microsoft.Jet.OLEDB.4.0'," & _
"'Excel 8.0;HDR=Yes;database=f:\YDSH\test.xls;'," & _
"'select * from [ACAD0001$]')"
cmd.ActiveConnection = conn
= strCmdSql
cmd.Execute
conn.Close
MsgBox "ok,数据已导入"
End Sub
以上是我的代码,但是text.xls数据库必须放到服务器的电脑里,怎么能将text.xls改到本地电脑里,请高手帮忙。