客戶端excel表如何導(dǎo)入遠(yuǎn)程sql server服務(wù)器
<%
'//客戶端上傳Excel,保存為upload/Excel.xls
.....
'//打開sql server
....
Conn.Open ...
'//打開Excel
Set ConnExcel = Server.Createobject("ADODB.Connection")
ExcelStr = "DBQ=" + server.mappath("upload/Excel.xls") + ";DRIVER={Microsoft Excel Driver (*.xls)};"
ConnExcel.Open ExcelStr
Set RSExcel = Server.CreateObject("ADODB.Recordset")
SQLExcel = "Select * From [Sheet1$]" '//你的Sheet1名
RSExcel.Open SQLExcel, ConnExcel, 3, 3
Set RS = Server.CreateObject("ADODB.RecordSet")
SQL = "Select * From [RegUser]"
RS.Open SQL, Conn, 1, 3
'----------------------------
'//添加begin
Do While Not RSExcel.EOF
RS.AddNew
For i=0 To RSExcel.Fields.Count-1
RS(i)=Trim(RSExcel(i))
Next
RS.Update
RSExcel.MoveNext
Loop
'//添加end
'----------------------------
RSExcel.Close
Set RSExcel = Nothing
RS.Close()
Set RS = Nothing
%>