问题描述:
我在个人blog数据库的blog_content(记录日志的)表里加了一个log_pwd的字段,用来储存日志的密码。
现在在首页里需要判断日志log_pwd字段的值是否为空,若为空就直接进入日志页面,非空则提示要输入密码以后才能进入。
由于日志的ID是自动增加的,应该怎样动态读取数据库里每一篇日志的密码呢?
谢谢了
解析:
<!--日志列表-->
<%
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open"select * from blog_content",conn,1,1
if rs.eof and rs.bof then
response.write ("没有数据")
else
response.write ("<table>")
for i=1 to 50 '打开数据从1到50循环'
response.write ("<tr><td><a href=日志显示页面?id=")&rs("log_id")&(">")&rs("日志字段名")&("</a></td><tr>") '这句话显示日志的题目链接'
rs.movenext
if rs.eof then exit for
next
response.write ("</table>")
end if
rs.close:set rs=nothing
%>
<!--日志显示页面-->
<%
id=request("id") '这儿的ID是获取上页面的ID号'
if not isnumeric id then id = "" '这儿是判断ID是否数字,如果不是则ID为空'
pwd=request("pwd") '这儿是获取密码'
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open"select * from blog_content where log_id="&id&"",conn,1,1 '这儿是打开log_id与ID相等的数据'
if rs.eof then
response.write ("没有找到相关文章")
else
if pwd = "" or pwd=rs("log_pwd") then
response.write rs("日志字段")
rs.close:set rs=nothing
else
%>
<form action="日志显示页面?id=<%rs("log_id")%>" method="post" name=pwd>
<input name=pwd type=text>
<input type=submit name=Submit value="提交">
</form>
<%
end if
end if
%>
没测试,不知道对不对,如果还有问题请加QQ***********
分类: 电脑/网络 >>程序设计 >>其他编程语言解析:
连接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 直接问吧
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)