ASP excel导出/导入Access数据库(代码+实例下载)
Excel导出函数
<%
Sub ExportToExcel
Response.ContentType = "application/vnd.ms-Excel"
Response.AddHeader "Content-Disposition", "attachment;Filename=Results.xls"
Response.Write "<body>"
Response.Write "<table border=1>"
Call WriteTableData
Response.Write "</table>"
Response.Write "</body>"
Response.Write "</html>"
End Sub
%>
Excel导入数据库
<%
dim FileName
FileName="Excel.xls" '取得文件名,来自项目经理的指定,路径固定在某个虚拟路径中
Dim conn, rs
set conn=CreateObject("ADODB.connection")
conn.Open "Driver={Microsoft Excel Driver (*.xls)};" & _
"DriverId=790;" & _
"Dbq=" & Server.mappath(""&FileName&"") & ";" & _
"DefaultDir=G:\"
set rs=createobject("ADODB.recordset")
rs.Open "Select * from [Sheet1$]",conn, 2, 2
if rs.eof then
response.write "Excel表中无纪录"
else
set connDB = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath("Excel.mdb")
'RESPONSE.WRITE DBpath
connDB.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
Set RsDB = Server.CreateObject("ADODB.Recordset")
SQLDB="Select * from Excel"
RsDB.open SQLDB,connDB,1,3
do while not rs.eof '利用循环读出数据
RsDB.addnew
RsDB("filename")=rs(0)
RsDB("id1")=rs(1)
RsDB("id2")=rs(2)
RsDB("id3")=rs(3)
RsDB("id4")=rs(4)
Rs.update
RsDB.movenext
rs.movenext
loop
'response.redirect FileName
end if
RsDB.movefirst
if RsDB.eof then
response.write "数据库中无记录"
else
do while not RsDB.EOF
response.write RsDB("filename")&" "
response.write RsDB("id1")&" "
response.write RsDB("id2")&" "
response.write RsDB("id3")&" "
response.write RsDB("id4")&" "
re
相关文档:
连接Access
首先看一个例子代码片断:
程序代码:
--------------------------------------------------------------------------------
using System.Data;
using System.Data.OleDb;
......
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\BegASPNET\Northwind.mdb" ......
dataurl=Server.MapPath("menutree.mdb")'数据库地址
dim conn,strQuery,rs
set conn = server.CreateObject("adodb.connection")
conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE="&dataurl
strQuery="select * from menufun"
set rs=server.createobject("adodb.recordset")
rs.open strQuery,conn,1 ......
Access 项目管理团队的 Clint 在此向 Office 工程博客的读者表示问候。通过与第 9 频道合作,Access 团队即将推出一个名为 Access 展示的新展示。其主要人物包括 Ryan McMinn、我本人以及团队的其他人员。我们将深入探讨 Access 2010 和 Access Services 中的新增功能,并分享来自社区的反馈。
此外,最近在 SharePoint D ......
1、分别安装三个环境,并设置不同端口
PHP:80
JSP:8080
ASP:8081
2、设置/Apache2/conf/httpd.conf
去掉以下三行前的注释:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
加入以下几行: ......
本节中的主题描述如何使用 Visual Web Developer 工具箱的“HTML”选项卡上的 ASP.NET Web 服务器控件。
默认情况下,服务器无法使用 ASP.NET 网页上的 HTML 元素;这些元素被视为传递给浏览器的不透明文本。但是,通过将 HTML 元素转换成 HTML 服务器控件,可以将它们公开为 ......