连接access数据库
asp数据库
一、
<%
dim conn
dim dbpath
set conn=servercreateobject("adodbconnection")
DBPath = ServerMapPath("8301asp")
connOpen "driver={Microsoft Access Driver (mdb)};dbq=" & DBPath
%>
二、
<%
Set Conn=ServerCreateObject("ADODBConnection")
Connstr="DBQ="+servermappath("rc/lzhasp")+";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("123456789/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数据库访问的路径
connasp的内容如下:
<%
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 直接问吧
<form action="">
<table width="160" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td width="55" height="30">类 别:</td>
<td width="105"><select name="style">
<option selected value="all">全部信息</option>
<option value="company">企业名</option>
<option value="ways">通知方式</option>
<option value="lxr">联系人</option>
</select></td>
</tr>
<tr align="center">
<td height="30">关键字:</td>
<td><input name="txtitle" type="text" class="input" size="15" value="请输入关键字" onFocus=thisvalue='' style="font-size:9pt; color:#FF0000;background-color:#F7F7F7;border-left: 1px solid rgb(192,192,192); border-right: 1px solid rgb(192,192,192); border-top: 1px solid rgb(192,192,192); border-bottom: 1px solid rgb(192,192,192)"></td>
</tr>
<tr align="center">
<td height="30"> </td>
<td><input type="submit" name="Submit3" value="查 询"></td>
</tr>
</table>
</form>
<%if request("txtitle")<>"" then
txtitle=request("txtitle") '搜索关键字内容
end if
if request("style")<>"" then
style=request("style")'搜索类别
end if
set rs=serverCreateObject("adodbrecordset")
if style="all" then'搜索所有的
sql="select from news where company like '%"&txtitle&"%' or ways like '%"&txtitle&"%' or lxr like '%"&txtitle&"%' order by id desc"
elseif style="company" then'按公司名
sql="select from news where title like '%"&txtitle&"%' order by id desc"
elseif style="ways" then '按通知方式
sql="select from news where ways like '%"&txtitle&"%' order by id desc"
elseif style="lxr" then '按联系人
sql="select from news where lxr like '%"&txtitle&"%' order by id desc"
else
sql="select from news where company like '%"&txtitle&"%' or ways like '%"&txtitle&"%' or lxr like '%"&txtitle&"%' order by id desc"
end if
rsopen sql,conn,1,1
rsPageSize =20
Page = CLng(Request("Page"))
'分页显示
If not Page >1 Then Page = 1
If Page > rsPageCount Then Page = rsPageCount
j=page+(page-1)9
rsAbsolutePage = Page
For i=1 To rsPageSize
if rseof then exit for
%>
可放入你自己想输出的内容
<%rsmovenext
next
%>
<form ACTION="" METHOD="post">
<tr>
<td height="25" align="center" bgcolor="#E1F4E1">共 <span class="org1"><%=rsRecordCount%></span>
条记录,<span class="org1"><%=rsPageCount%></span> 页,当前第 <span class="org1"><%=Page%></span>
页。<%If Page <> 1 Then%>
[<a href="Page=1">
首页</a>]
[<a HREF="Page=<%=(Page-1)%>">
前一页</a>]
<% End If
If Page <> rspageCount Then
%> [<a HREF="Page=<%=(Page+1)%>">
后一页</a>]
[<a HREF="Page=<%=rsPageCount%>">
末页</a>] <%End If %>
输入页次: <input NAME="Page" SIZE="3"></td>
</tr></form>
</table>
包 含330 select from 表名称 where 编号字段名 like '%003%'
前三位为330 select from 表名称 where 编号字段名 like '003%'
后三位为330 select from 表名称 where 编号字段名 like '%003'
1
select
from
news
where
leibie=1
2
select
top
500
from
news
order
by
id
asc
3
ACCESS貌似还没有实现过
有个笨办法
先把500插入到一个表中
在100排列
然后400排列
4
select
top
400
from
news
where
id
mod
2<>0 order
by
id
desc
以上就是关于ASP 如何实现查询 数据库文件!全部的内容,包括:ASP 如何实现查询 数据库文件!、用ASP搜索数据库~、asp中如何搜索数据库中指定位置的字符等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)