ASP 如何实现查询 数据库文件!

ASP 如何实现查询 数据库文件!,第1张

分类: 电脑/网络 >>程序设计 >>其他编程语言

解析:

连接access数据库

asp数据库

一、

<%

dim conn

dim dbpath

set conn=server.createobject("adodb.connection")

DBPath = Server.MapPath("8301")

conn.Open "driver={Microsoft Access Driver (*.mdb)}dbq=" &DBPath

%>

二、

<%

Set Conn=Server.CreateObject("ADODB.Connection")

Connstr="DBQ="+server.mappath("rc/lzh")+"DefaultDir=DRIVER={Microsoft Access Driver (*.mdb)}"

Conn.Open connstr

%>

dim ipconn

set ipconn=server.createobject("ADODB.CONNECTION")

ipconn.open "DBQ="&server.mappath("ip.mdb")&"DRIVER={Microsoft Access Driver (*.mdb)}"

dim rs,sql

Set rs = Server.CreateObject("ADODB.Recordset")

sql="select top 1 ip_b,ip_c from ip where (ip_s<=" &ip &" and ip_e>=" &ip &")"

rs.Open sql,ipconn,1,1

if rs.eof or rs.bof then

getaddress="未知|未知"

Else

getaddress=rs(0)&"|"&rs(1)

end if

mdb数据库

一、

<%dim coon

Set Conn=Server.CreateObject("ADODB.Connection")

Connstr="DBQ="+server.mappath("***********/123.mdb")+"DefaultDir=DRIVER={Microsoft Access Driver (*.mdb)}"

Conn.Open connstr

%>

二、

dim conn

set conn = server.createobject("adodb.connection")

conn.open = "provider=microsoft.jet.oledb.4.0" &"data source = " &server.mappath("../db/bbs.mdb")

三、

<%@ language=VBs cript%>

<%

dim conn,mdbfile

mdbfile=server.mappath("数据库名称.mdb")

set conn=server.createobject("adodb.connection")

conn.open "driver={microsoft access driver (*.mdb)}uid=adminpwd=数据库密码dbq="&mdbfile

%>

set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")

DBPath = Server.MapPath("customer.mdb")

dbconnection.Open "driver={Microsoft Access Driver (*.mdb)}dbq=" &DBPath

SQL="select * from auth where id='" &user_id &"'"

SET uplist=dbconnection.EXECUTE(SQL)

2.

set dbconnection=Server.CreateObject("ADODB.Connection")

DBPath = Server.MapPath("customer.mdb")

dbconnection.Open "provider=microsoft.jet.oledb.4.0data source="&dbpath

SQL="select * from auth where id='" &user_id &"'"

SET uplist=dbconnection.EXECUTE(SQL)

3.

DBPath = Server.MapPath("customer.mdb")

set session("rs")=Server.CreateObject("ADODB.Recordset")

' rs=Server.CreateObject("ADODB.Recordset")

connstr="provider=microsoft.jet.oledb.4.0data source="&dbpath

SQL="select * from auth where id='" &user_id &"'"

session("rs").Open sql,connstr,1,3

4.

建odbc源xxx

set conn=server.createobject("Adodb.connection")

conn.open "DSN=xxxUID=PWD=Database=customer

SetConn=Server.CreateObject("ADODB.Connection")

Connstr="DBQ="+server.mappath("aaa/bbspp1.mdb")+"DefaultDir=

DRIVER={Microsoft AccessDriver(*.mdb)}DriverId=25FIL=MSAccess

ImplicitCommitSync=Yes

MaxBufferSize=512MaxScanRows=8PageTimeout=5SafeTransactions=0

Threads=3UserCommitSync=Yes"

Conn.Openconnstr

说明: 其中SetConn=Server.CreateObject("ADODB.Connection")为建立一个访问数据的对象, server.mappath(aaa/bbspp1.mdb)是告诉服务器access数据库访问的路径

conn的内容如下:

<%

dim conn,rs

set conn=server.createobject("adodb.connection")

conn.open "driver={microsoft access driver (*.mdb)}dbq="&server.mappath("mdb/mfkiqpl.mdb ")

set rs=server.createobject("adodb.recordset")

set rs.activeconnection=conn

%>

还不懂啊 加偶的QQ 直接问吧

OleDbDataReader

是一个读取器,不能直接作为数据源赋给GridView

OleDbDataReader

dr

=

com.ExecuteReader()

dataset

ds=new

dataset

()

dr.Fill(ds)

GridView1.DataSource

=

ds.tabels[0]


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10035101.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-04
下一篇 2023-05-04

发表评论

登录后才能评论

评论列表(0条)

保存