谁知道将excel表中的字段导入到access表中对应的字段包含数据库。
展开全部
我空间上有代码。
path="./"
Dim xlsconn,strsource,xlbook,xlsheet,i
Dim myConn_Xsl,xlsrs,sql,objCmd
Set xlsconn = server.CreateObject("adodb.connection")
Set xlsrs = Server.CreateObject("Adodb.RecordSet")
filename=request("form2")
file2="Sheet1"
source=server.mappath(path&filename)
myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &source& ";Extended Properties=Excel 8.0"
xlsconn.open myConn_Xsl
sql = "Select * from ["&file2&"$]"
xlsrs.open sql,xlsconn,1,1
If xlsrs.eof Then
else
i=1
Do While not xlsrs.eof
goods_name=xlsrs("Table_Name")
sql="insert into goods(bh) values('"&goods_name&"')"
conn1.execute(sql)
i=i+1
xlsrs.MoveNext
Loop
End If
xlsrs.close
Response.write "共导入<font color='red'>" & i-1 & "</font>条记录.[<a href='rz_user.asp?action=2'>点击管理</a>]<br>" & vbCrLf
set xlsconn=nothing
set objCmd=Nothing
path="./"
Dim xlsconn,strsource,xlbook,xlsheet,i
Dim myConn_Xsl,xlsrs,sql,objCmd
Set xlsconn = server.CreateObject("adodb.connection")
Set xlsrs = Server.CreateObject("Adodb.RecordSet")
filename=request("form2")
file2="Sheet1"
source=server.mappath(path&filename)
myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &source& ";Extended Properties=Excel 8.0"
xlsconn.open myConn_Xsl
sql = "Select * from ["&file2&"$]"
xlsrs.open sql,xlsconn,1,1
If xlsrs.eof Then
else
i=1
Do While not xlsrs.eof
goods_name=xlsrs("Table_Name")
sql="insert into goods(bh) values('"&goods_name&"')"
conn1.execute(sql)
i=i+1
xlsrs.MoveNext
Loop
End If
xlsrs.close
Response.write "共导入<font color='red'>" & i-1 & "</font>条记录.[<a href='rz_user.asp?action=2'>点击管理</a>]<br>" & vbCrLf
set xlsconn=nothing
set objCmd=Nothing
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询