解析:
连接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 直接问吧
我修改了一下你试试,都标记出来了 <%dim conn,db,rs,sqldim ip,jcip,jcrs,jcsql,jcconn
db="ip2009.mdb" '这个是数据库路径
ip=request.ServerVariables("REMOTE_ADDR") '获取来访的IP地址
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath(db)
sql="select * from ip2009 where userip='"&ip&"'"'改的第一处
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,2
if not rs.eof and rs.bof then '改的第二处
rs.close
conn.close
set conn=nothing
%>
数据库路径错误!
<%
elsers.addnew
rs("userip")=ip
rs.update
%>
已经成功添加纪录!
<% rs.close
conn.close
set conn=nothing
end if '改的第三处
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)