这有一个参考,网上有很多类似的导入资料。
<%
dim conn
dim conn2
set conn=CreateObject("ADODB.Connection")
'.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=C:\TestAsp\book1.mdb"
conn.Open "driver={sql server};server=.;uid=sa;pwd=jack;database=jack"
set conn2=CreateObject("ADODB.Connection")
'conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Extended properties=Excel 5.0;Data Source=C:\TestAsp\book1.xls"
conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended properties=Excel 5.0;Data Source=C:\TestAsp\book1.xls"
sql = "SELECT * FROM [Sheet1$]"
set rs = conn2.execute(sql)
while not rs.eof
'sql = "insert into Table3([userId],[userName],[userPass]) values('"& fixsql(rs(0)) &"','"& fixsql(rs(1)) &"','"& fixsql(rs(2)) &"')"
sql = "insert into Table4([userName],[userPass]) values('"& fixsql(rs(0)) &"','"& fixsql(rs(1)) &"')"
conn.execute(sql)
rs.movenext
wend
conn.close
set conn = nothing
conn2.close
set conn2 = nothing
function fixsql(str)
dim newstr
newstr = str
if isnull(newstr) then
newstr = ""
else
newstr = replace(newstr,"'","''")
end if
fixsql = newstr
end function
%>
<input name="" type="button" value="测试" />