分类: 电脑/网络 >> 程序设计 >> 其他编程语言
解析:
连接access数据库
asp数据库
一、
<%
dim conn
dim dbpath
set conn=servercreateobject("adodbconnection")
DBPath = ServerMapPath("8301")
connOpen "driver={Microsoft Access Driver (mdb)};dbq=" & DBPath
%>
二、
<%
Set Conn=ServerCreateObject("ADODBConnection")
Connstr="DBQ="+servermappath("rc/lzh")+";DefaultDir=;DRIVER={Microsoft Access Driver (mdb)}"
ConnOpen connstr
%>
dim ipconn
set ipconn=servercreateobject("ADODBCONNECTION")
ipconnopen "DBQ="&servermappath("ipmdb")&";DRIVER={Microsoft Access Driver (mdb)};"
dim rs,sql
Set rs = ServerCreateObject("ADODBRecordset")
sql="select top 1 ip_b,ip_c from ip where (ip_s<=" & ip & " and ip_e>=" & ip & ")"
rsOpen sql,ipconn,1,1
if rseof or rsbof then
getaddress="未知|未知"
Else
getaddress=rs(0)&"|"&rs(1)
end if
mdb数据库
一、
<%dim coon
Set Conn=ServerCreateObject("ADODBConnection")
Connstr="DBQ="+servermappath("/123mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (mdb)}"
ConnOpen connstr
%>
二、
dim conn
set conn = servercreateobject("adodbconnection")
connopen = "provider=microsoftjetoledb40;" & "data source = " & servermappath("/db/bbsmdb")
三、
<%@ language=VBs cript%>
<%
dim conn,mdbfile
mdbfile=servermappath("数据库名称mdb")
set conn=servercreateobject("adodbconnection")
connopen "driver={microsoft access driver (mdb)};uid=admin;pwd=数据库密码;dbq="&mdbfile
%>
set dbconnection=ServerCREATEOBJECT("ADODBCONNECTION")
DBPath = ServerMapPath("customermdb")
dbconnectionOpen "driver={Microsoft Access Driver (mdb)};dbq=" & DBPath
SQL="select from auth where id='" & user_id &"'"
SET uplist=dbconnectionEXECUTE(SQL)
2
set dbconnection=ServerCreateObject("ADODBConnection")
DBPath = ServerMapPath("customermdb")
dbconnectionOpen "provider=microsoftjetoledb40;data source="&dbpath
SQL="select from auth where id='" & user_id &"'"
SET uplist=dbconnectionEXECUTE(SQL)
3
DBPath = ServerMapPath("customermdb")
set session("rs")=ServerCreateObject("ADODBRecordset")
' rs=ServerCreateObject("ADODBRecordset")
connstr="provider=microsoftjetoledb40;data source="&dbpath
SQL="select from auth where id='" & user_id &"'"
session("rs")Open sql,connstr,1,3
4
建odbc源xxx
set conn=servercreateobject("Adodbconnection")
connopen "DSN=xxx;UID=;PWD=;Database=customer
SetConn=ServerCreateObject("ADODBConnection")
Connstr="DBQ="+servermappath("aaa/bbspp1mdb")+";DefaultDir=;
DRIVER={Microsoft AccessDriver(mdb)};DriverId=25;FIL=MSAccess;
ImplicitCommitSync=Yes;
MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;
Threads=3;UserCommitSync=Yes;"
ConnOpenconnstr
说明: 其中SetConn=ServerCreateObject("ADODBConnection")为建立一个访问数据的对象, servermappath(aaa/bbspp1mdb)是告诉服务器access数据库访问的路径
conn的内容如下:
<%
dim conn,rs
set conn=servercreateobject("adodbconnection")
connopen "driver={microsoft access driver (mdb)};dbq="&servermappath("mdb/mfkiqplmdb ")
set rs=servercreateobject("adodbrecordset")
set rsactiveconnection=conn
%>
还不懂啊 加偶的QQ 直接问吧
下面是asp中的代码
Set rs2=ServerCreateObject(ADODBrecordset)
sql=select from eq where eqbumen='&dep;&' order by eqbumen desc
rs2open sql,conn,1,1
set objExcel=CreateObject(ExcelApplication)
objExcelWorkbooksOpen(servermappath(\test)&\book1xlt) '打开Excel模板
objExcelSheets(1)select '选中工作页
set sheetActive=objExcelActiveWorkbookActiveSheet
num=2 '从Excel的第2行开始
Do while not rs2eof '循环直至数据集中的数据写完
strRange=b#&:k# '设定要填写内容的单元区域
sheetActiverange(strRange)fontsize=10 '设定字体大小
sheetActiverange(strRange)WrapText=false '设定文字回卷
sheetActiverange(strRange)ShrinkToFit=true '设定是否自动适应表格单元大小
sheetActiverange(strRange)value=array(rs2(zcid),rs2(eqname),rs2(eqchangjia),rs2(eqxinghao),rs2(eqnengli),rs2(eqweizhi),rs2(eqxianzhuang),rs2(eqno),rs2(eqbumen),rs2(eqchejian)) '把数据集中的数据填写到相应的单元中
num=num+1
rs2MoveNext
loop
function getTemporaryFile(myFileSystem)
dim tempFile,dotPos
tempFile=myFileSystemgetTempName
dotPos=instr(1,tempFile,)
getTemporaryFile=mid(tempFile,1,dotPos)&xls; end function
set myFs=createObject(scriptingFileSystemObject)
filePos=servermappath(\test)&\temp '要存放打印临时文件的临时目录
fileName=getTemporaryFile(myFs) '取得一个临时文件名
'myFsDeleteFile filePos&xls '删除该目录下所有原先产生的临时打印文件
set myFs=nothing
objExcelActiveWorkbooksaveas filePos&filename;
objExcelquit
set objExcel=Nothing。
用的最多的就是ACCESS和SQL
Server数据库,连接语句如下:
1
ASP连接Aess数据库语句
Set
Conn=Server("ADODBConnection")
Connstr="DBQ="servermappath(">
AessDriver(mdb)};"
ConnOpen
connstr
其中Set
Conn=Server("ADODBConnection")为建立一个访问数据的对象
servermappath(">
数据库访问的路径
2
ASP连接Sqlserver数据库语句
Set
conn
=
Server("ADODBConnection")
connOpen"driver={SQLServer};server=2021083294;uid=wu77445;pwd=p780522;database=w
ww_panwei_com"
conn
open
其中/Set
conn
=
Server("ADODBConnection")为设置一个数据库的连接对象
driver=()告诉连接的设备名是SQL-SERVER
server是连接的服务器的ip地址,Uid是指用户的用户名,pwd是指的用户的password,database是用户数据库在服务器端的数据库的名称
以上就是关于ASP 如何实现查询 数据库文件!全部的内容,包括:ASP 如何实现查询 数据库文件!、asp如何将数据库中的数据输出到表格中并修改 asp输出方法、ASp连接数据库(ASP连接数据库时,可以使用哪三种方式的连接方法)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)