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" ......
Microsoft ASP.NET学习笔记(1)我眼中的ASP.NET
以前一直用的Java, J2EE平台,现在因为课题需要初学了一下ASP.NET,小谈一下二者做WEB开发的体会。
都说.NET做WEB开发效率高,我的体会就是MS的东西用着就是方便,一个控件放上去,设几个属性,填几个事件,写几个SQL,就成了,觉得这种模式跟原来ASP的那个代码运行起来效 ......
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
加入以下几行: ......
以win2003操作系统,硬盘采用NTFS文件系统。网站的权限设置包含两部分:主要是网站文件夹与文件的访问权限,其次是IIS中的internet匿名用户的访问权限。
一、网站文件夹与文件访问权限的设置
假设ASP网站在以下文件夹中:web 、bbs,我们称其为网站根文件夹。
1、相同的设置
(1)本地用户一般都要对站点内的文件夹和文 ......
最近做一个用asp做的网站后台的数据导出功能时,google,baidu了很多,但是多数都是转载,代码大概都一样,但是就是报错,最后有人说通过设置MIME类型和建立模板,最后整理,测试问题终于解决.关键的地方有以下几点:
1):MIME类型要设置正确,如要把DB中表(或表中指定字段)的数据导出成exel格式时,头部的MEMI类型的设置是:
<%
......