asp怎么实现简单的ajax留言板
发表于:2025-01-17 作者:千家信息网编辑
千家信息网最后更新 2025年01月17日,这篇文章主要介绍"asp怎么实现简单的ajax留言板",在日常操作中,相信很多人在asp怎么实现简单的ajax留言板问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"asp
千家信息网最后更新 2025年01月17日asp怎么实现简单的ajax留言板
<%=myList%>
BLL_Guest.asp
<%
'///
'/// 摘要说明。
'///
Class BLL_Guest
Private mycom,mymod,mydal
Private LI,UL
Private DEL
'获取信息
Public Sub GetGuest()
mydal.GetGuest(Id)
End Sub
'新增信息
Public Sub Insert()
mymod.Content = Request("content")
mymod.re = Request("Re")
mymod.Addtime = Now()
mymod.Ip = request.servervariables("HTTP_X_FORWARDED_FOR")
If len(mymod.Ip)<=0 Then mymod.Ip = request.servervariables("REMOTE_ADDR")
Call mydal.Insert(mymod)
End Sub
'更新信息
Public Sub Update()
Call mydal.Update(mymod)
End Sub
'删除信息
Public Sub Delete()
mydal.Delete(Request("Id"))
End Sub
'查找信息
Public Function FindByPage()
Dim PageSize,CurrentPage,WhereValue,OrderValue,RecordCount
Dim objRS
Dim tmp1,tmp2,tmp3,parms,i
Dim tCMD
tCMD = Request("tCMD")
PageSize = "8"
CurrentPage = Request("PageNo")
If Len(CurrentPage)<=0 Then
CurrentPage=1
End If
WhereValue = ""
OrderValue = "Id"
Set objRS = mydal.FindByPage(PageSize,CurrentPage-1,WhereValue,OrderValue)
i = 1
RecordCount = mydal.Count(WhereValue)
Do While Not objRS.EOF
If tCMD="DEL" Then
DEL = "删除"
Else
DEL = ""
End If
parms=Array(i,objRS("content"),objRS("ip"),objRS("addtime"),DEL)
tmp1 = tmp1 & mycom.Format(LI,parms)
objRs.Movenext
i = i + 1
Loop
tmp3 = mycom.Page(PageSize,CurrentPage,RecordCount,"guest/index.asp?tCMD=LIST")
parms=Array(tmp1,tmp3)
tmp2 = tmp2 & mycom.Format(UL,parms)
FindByPage = tmp2
End Function
Private Sub Class_Initialize()
LI = "{0} {1}
作者:{2} {3} {4} " & vbCrLf
UL = "
DEL = ""
Set mycom = new Common
set mymod = new MOD_Guest
set mydal = new DAL_Guest
End Sub
Private Sub Class_Terminate()
Set mycom = Nothing
Set mymod = Nothing
set mydal = Nothing
End Sub
End Class
%>
DAL_Guest.asp
<%
'///
'/// 摘要说明。
'///
Class DAL_Guest
Private SQL_01
Private SQL_02
Private SQL_03
Private SQL_04
Private SQL_05
Private SQL_06
Private SQL_07
Private mycom,myacc,mymod
'///
'/// 获得信息
'///
'/// 判断字段
'///信息体
Public Function GetGuest(Id)
Dim parms,SQL,objRS
parms = Array(Id)
SQL = mycom.Format(SQL_01,parms)
Set objRS = myacc.ExecuteReader(myacc.CONN_STRING,SQL)
If Not objRS.EOF then
Call mymod.SetVar(objRs("Id"),objRs("Content"),objRs("Re"),objRs("Addtime"),objRs("Ip"))
Set GetGuest = mymod
Else
GetGuest = Null
End If
End Function
'///
'/// 插入信息
'///
'/// 信息体
Public Sub Insert(vmod)
Dim parms,SQL
parms = Array(vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
SQL = mycom.Format(SQL_02,parms)
Call myacc.ExecuteReader(myacc.CONN_STRING,SQL)
End Sub
'///
'/// 更新信息
'///
'/// 信息体
Public Sub Update(vmod)
Dim parms,SQL
parms = Array(vmod.Id,vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
SQL = mycom.Format(SQL_03,parms)
Call myacc.ExecuteReader(myacc.CONN_STRING,SQL)
End Sub
'///
'/// 删除信息
'///
'/// 信息体
Public Sub Delete(Id)
Dim parms,SQL
parms = Array(Id)
SQL = mycom.Format(SQL_04,parms)
Call myacc.ExecuteNonQuery(myacc.CONN_STRING,SQL)
End Sub
'///
'/// 统计信息
'///
'/// 信息体
Public Function Count(WhereValue)
Dim parms,SQL,objRS
parms = Array(WhereValue)
SQL = mycom.Format(SQL_07,parms)
Set objRS = myacc.Recordset(myacc.CONN_STRING,SQL)
Count = objRS.RecordCount
End Function
'///
'/// 根据条件列出所有信息(带有分页)
'///
'/// 每页记录数
'/// 页码
'/// 判断值
'/// 排序
'///返回objRS
Public Function FindByPage(PageSize,CurrentPage,WhereValue,OrderValue)
Dim parms,SQL,objRS
Dim s1
If CurrentPage="0" Then
s1 = PageSize & "|" + OrderValue & "|" & WhereValue
parms = Split(s1,"|")
SQL = mycom.Format(SQL_05,parms)
Else
s1 = PageSize & "|" & OrderValue & "|" + WhereValue & "|" & CurrentPage*PageSize
parms = Split(s1,"|")
SQL = mycom.Format(SQL_06,parms)
End If
Set objRS = myacc.ExecuteReader(myacc.CONN_STRING,SQL)
Set FindByPage = objRS
End Function
Private Sub Class_Initialize()
SQL_01 = "Select * From [Guest] Where Id = {0}"
SQL_02 = "Insert into [Guest] ([Content],[Re],[Addtime],[Ip]) values('{0}','{1}','{2}','{3}')"
SQL_03 = "Update [Guest] Set [Content]='{1}',[Re]='{2}',[Addtime]='{3}',[Ip]='{4}' Where Id = {0}"
SQL_04 = "Delete From [Guest] Where Id In ({0})"
SQL_05 = "Select Top {0} * From [Guest] Where Content Like '%{2}%' Order By {1} Desc,Id Desc"
SQL_06 = "Select Top {0} * From [Guest] Where Content Like '%{2}%' And Id Not IN(Select Top {3} Id From [Guest] Where Content Like '%{2}%' Order By {1} Desc,Id Desc) Order By {1} Desc,Id Desc"
SQL_07 = "Select * From [Guest] Where Content Like '%{0}%' "
Set mycom = new Common
Set myacc = new AccHelper
Set mymod = new MOD_Guest
End Sub
Private Sub Class_Terminate()
Set mycom = Nothing
Set myacc = Nothing
Set mymod = Nothing
End Sub
End Class
%>
MOD_Guest.asp
<%
'///
'/// 摘要说明。
'///
Class MOD_Guest
Public Id
Public Content
Public Re
Public Addtime
Public Ip
Public Sub SetVar(vId,vContent,vRe,vAddtime,vIp)
Id=vId
Content=vContent
Re=vContent
Addtime=vAddtime
Ip=vIp
End Sub
End Class
%>
Common.asp
<%
'///
'/// 摘要说明
'///
Class Common
'///
'/// 获得信息
'///
'/// 需要内容
'/// 替换关键字
'///格式化后内容
Public Function Format(str,arr)
Dim r,i
r = str
For i = 0 To UBound(arr)
r = Replace(r,"{"&i&"}",arr(i))
Next
Format = r
End Function
Public Function Page(PageSize,CurrentPage,RecordCount,PageUrl)
const C_RECORDCOUNT = "合计{0}篇 |"
const C_FIRSTPAGE1 = " 首页"
const C_FIRSTPAGE2 = " 首页"
const C_PREVPAGE1 = " 上一页"
const C_PREVPAGE2 = " 上一页"
const C_NEXTPAGE1 = " 下一页"
const C_NEXTPAGE2 = " 下一页"
const C_LASTPAGE1 = " 尾页"
const C_LASTPAGE2 = " 尾页"
const C_CURRENTPAGE = " 页次:{0}/{1}页"
const C_PAGESIZE = " {0}篇/页 "
const C_GOTOPAGE = " 跳转: "
Dim PageCount,pages
Dim lRecordCount,lFirstpage,lPrevpage,lNextpage,lLastpage,lCurrentpage,lPagesize,lGotopage
Dim p,parms
If RecordCount Mod PageSize <> 0 Then
pages = 1
else
pages = 0
End If
PageCount=CInt(RecordCount/PageSize + pages)
parms=Array(RecordCount)
lRecordCount = Format(C_RECORDCOUNT,parms)
if CInt(CurrentPage)>1 Then
parms=Array(Pageurl,1)
lFirstpage = Format(C_FIRSTPAGE1,parms)
parms=Array(Pageurl,CInt(CurrentPage)-1)
lPrevpage = Format(C_PREVPAGE1,parms)
Else
lFirstpage=C_FIRSTPAGE2
lPrevpage=C_PREVPAGE2
End If
if CInt(CurrentPage)parms=Array(Pageurl,CInt(CurrentPage)+1)
lNextpage = Format(C_NEXTPAGE1,parms)
parms=Array(Pageurl,CInt(CurrentPage)+1)
lLastpage = Format(C_LASTPAGE1,parms)
Else
lNextpage=C_NEXTPAGE2
lLastpage=C_LASTPAGE2
End If
parms=Array(CurrentPage,PageCount)
lCurrentpage = Format(C_CURRENTPAGE,parms)
parms=Array(PageSize)
lPagesize = Format(C_PAGESIZE,parms)
parms=Array(Pageurl,CurrentPage)
lGotopage = Format(C_GOTOPAGE,parms)
p=lRecordCount&lFirstpage&lPrevpage&lNextpage&lLastpage&lCurrentpage&lPagesize&lGotopage
Page = p
End Function
End Class
%>
AccHelper.asp
<%
'///
'/// AccHelper 的摘要说明。
'///
Class AccHelper
Public CONN_STRING
'///
'/// 执行ExecuteNonQuery
'///
'/// 连接字符
'/// sql命令
Public Function ExecuteNonQuery(connString,cmdText)
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open connString
objConn.Execute(cmdText)
End Function
'///
'/// 执行ExecuteReader
'///
'/// 连接字符
'/// sql命令
'///RS
Public Function ExecuteReader(connString,cmdText)
Dim objConn,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open connString
Set objRS = objConn.Execute(cmdText)
Set ExecuteReader = objRS
End Function
'///
'/// 执行Recordset
'///
'/// 连接字符
'/// sql命令
'///RS
Public Function Recordset(connString,cmdText)
Dim objConn,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open connString
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open cmdText,objConn,1,3
Set Recordset = objRS
End Function
Private Sub Class_Initialize()
CONN_STRING = "provider = microsoft.jet.oledb.4.0;data source=" & Server.Mappath("db.mdb")
End Sub
End Class
%>
这篇文章主要介绍"asp怎么实现简单的ajax留言板",在日常操作中,相信很多人在asp怎么实现简单的ajax留言板问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答"asp怎么实现简单的ajax留言板"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
代码如下:
<%@ codepage=65001%>
<%
option explicit
%>
<% Response.Charset="utf-8"%>
<% Session.CodePage=65001 %>
<%
Dim mybll
Dim myList
Set mybll = new BLL_Guest
Select Case Request("tCMD")
Case "SAVE"
mybll.Insert()
Case "DEL"
mybll.Delete()
End Select
myList = mybll.FindByPage()
%>
客户留言
<%=myList%>
BLL_Guest.asp
<%
'///
'/// 摘要说明。
'///
Class BLL_Guest
Private mycom,mymod,mydal
Private LI,UL
Private DEL
'获取信息
Public Sub GetGuest()
mydal.GetGuest(Id)
End Sub
'新增信息
Public Sub Insert()
mymod.Content = Request("content")
mymod.re = Request("Re")
mymod.Addtime = Now()
mymod.Ip = request.servervariables("HTTP_X_FORWARDED_FOR")
If len(mymod.Ip)<=0 Then mymod.Ip = request.servervariables("REMOTE_ADDR")
Call mydal.Insert(mymod)
End Sub
'更新信息
Public Sub Update()
Call mydal.Update(mymod)
End Sub
'删除信息
Public Sub Delete()
mydal.Delete(Request("Id"))
End Sub
'查找信息
Public Function FindByPage()
Dim PageSize,CurrentPage,WhereValue,OrderValue,RecordCount
Dim objRS
Dim tmp1,tmp2,tmp3,parms,i
Dim tCMD
tCMD = Request("tCMD")
PageSize = "8"
CurrentPage = Request("PageNo")
If Len(CurrentPage)<=0 Then
CurrentPage=1
End If
WhereValue = ""
OrderValue = "Id"
Set objRS = mydal.FindByPage(PageSize,CurrentPage-1,WhereValue,OrderValue)
i = 1
RecordCount = mydal.Count(WhereValue)
Do While Not objRS.EOF
If tCMD="DEL" Then
DEL = "删除"
Else
DEL = ""
End If
parms=Array(i,objRS("content"),objRS("ip"),objRS("addtime"),DEL)
tmp1 = tmp1 & mycom.Format(LI,parms)
objRs.Movenext
i = i + 1
Loop
tmp3 = mycom.Page(PageSize,CurrentPage,RecordCount,"guest/index.asp?tCMD=LIST")
parms=Array(tmp1,tmp3)
tmp2 = tmp2 & mycom.Format(UL,parms)
FindByPage = tmp2
End Function
Private Sub Class_Initialize()
LI = "
作者:{2} {3} {4}
UL = "
- {0}
- {1}
DEL = ""
Set mycom = new Common
set mymod = new MOD_Guest
set mydal = new DAL_Guest
End Sub
Private Sub Class_Terminate()
Set mycom = Nothing
Set mymod = Nothing
set mydal = Nothing
End Sub
End Class
%>
DAL_Guest.asp
<%
'///
'/// 摘要说明。
'///
Class DAL_Guest
Private SQL_01
Private SQL_02
Private SQL_03
Private SQL_04
Private SQL_05
Private SQL_06
Private SQL_07
Private mycom,myacc,mymod
'///
'/// 获得信息
'///
'/// 判断字段
'///
Public Function GetGuest(Id)
Dim parms,SQL,objRS
parms = Array(Id)
SQL = mycom.Format(SQL_01,parms)
Set objRS = myacc.ExecuteReader(myacc.CONN_STRING,SQL)
If Not objRS.EOF then
Call mymod.SetVar(objRs("Id"),objRs("Content"),objRs("Re"),objRs("Addtime"),objRs("Ip"))
Set GetGuest = mymod
Else
GetGuest = Null
End If
End Function
'///
'/// 插入信息
'///
'/// 信息体
Public Sub Insert(vmod)
Dim parms,SQL
parms = Array(vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
SQL = mycom.Format(SQL_02,parms)
Call myacc.ExecuteReader(myacc.CONN_STRING,SQL)
End Sub
'///
'/// 更新信息
'///
'/// 信息体
Public Sub Update(vmod)
Dim parms,SQL
parms = Array(vmod.Id,vmod.Content,vmod.Re,vmod.Addtime,vmod.Ip)
SQL = mycom.Format(SQL_03,parms)
Call myacc.ExecuteReader(myacc.CONN_STRING,SQL)
End Sub
'///
'/// 删除信息
'///
'/// 信息体
Public Sub Delete(Id)
Dim parms,SQL
parms = Array(Id)
SQL = mycom.Format(SQL_04,parms)
Call myacc.ExecuteNonQuery(myacc.CONN_STRING,SQL)
End Sub
'///
'/// 统计信息
'///
'/// 信息体
Public Function Count(WhereValue)
Dim parms,SQL,objRS
parms = Array(WhereValue)
SQL = mycom.Format(SQL_07,parms)
Set objRS = myacc.Recordset(myacc.CONN_STRING,SQL)
Count = objRS.RecordCount
End Function
'///
'/// 根据条件列出所有信息(带有分页)
'///
'/// 每页记录数
'/// 页码
'/// 判断值
'/// 排序
'///
Public Function FindByPage(PageSize,CurrentPage,WhereValue,OrderValue)
Dim parms,SQL,objRS
Dim s1
If CurrentPage="0" Then
s1 = PageSize & "|" + OrderValue & "|" & WhereValue
parms = Split(s1,"|")
SQL = mycom.Format(SQL_05,parms)
Else
s1 = PageSize & "|" & OrderValue & "|" + WhereValue & "|" & CurrentPage*PageSize
parms = Split(s1,"|")
SQL = mycom.Format(SQL_06,parms)
End If
Set objRS = myacc.ExecuteReader(myacc.CONN_STRING,SQL)
Set FindByPage = objRS
End Function
Private Sub Class_Initialize()
SQL_01 = "Select * From [Guest] Where Id = {0}"
SQL_02 = "Insert into [Guest] ([Content],[Re],[Addtime],[Ip]) values('{0}','{1}','{2}','{3}')"
SQL_03 = "Update [Guest] Set [Content]='{1}',[Re]='{2}',[Addtime]='{3}',[Ip]='{4}' Where Id = {0}"
SQL_04 = "Delete From [Guest] Where Id In ({0})"
SQL_05 = "Select Top {0} * From [Guest] Where Content Like '%{2}%' Order By {1} Desc,Id Desc"
SQL_06 = "Select Top {0} * From [Guest] Where Content Like '%{2}%' And Id Not IN(Select Top {3} Id From [Guest] Where Content Like '%{2}%' Order By {1} Desc,Id Desc) Order By {1} Desc,Id Desc"
SQL_07 = "Select * From [Guest] Where Content Like '%{0}%' "
Set mycom = new Common
Set myacc = new AccHelper
Set mymod = new MOD_Guest
End Sub
Private Sub Class_Terminate()
Set mycom = Nothing
Set myacc = Nothing
Set mymod = Nothing
End Sub
End Class
%>
MOD_Guest.asp
<%
'///
'/// 摘要说明。
'///
Class MOD_Guest
Public Id
Public Content
Public Re
Public Addtime
Public Ip
Public Sub SetVar(vId,vContent,vRe,vAddtime,vIp)
Id=vId
Content=vContent
Re=vContent
Addtime=vAddtime
Ip=vIp
End Sub
End Class
%>
Common.asp
<%
'///
'/// 摘要说明
'///
Class Common
'///
'/// 获得信息
'///
'/// 需要内容
'/// 替换关键字
'///
Public Function Format(str,arr)
Dim r,i
r = str
For i = 0 To UBound(arr)
r = Replace(r,"{"&i&"}",arr(i))
Next
Format = r
End Function
Public Function Page(PageSize,CurrentPage,RecordCount,PageUrl)
const C_RECORDCOUNT = "合计{0}篇 |"
const C_FIRSTPAGE1 = " 首页"
const C_FIRSTPAGE2 = " 首页"
const C_PREVPAGE1 = " 上一页"
const C_PREVPAGE2 = " 上一页"
const C_NEXTPAGE1 = " 下一页"
const C_NEXTPAGE2 = " 下一页"
const C_LASTPAGE1 = " 尾页"
const C_LASTPAGE2 = " 尾页"
const C_CURRENTPAGE = " 页次:{0}/{1}页"
const C_PAGESIZE = " {0}篇/页 "
const C_GOTOPAGE = " 跳转: "
Dim PageCount,pages
Dim lRecordCount,lFirstpage,lPrevpage,lNextpage,lLastpage,lCurrentpage,lPagesize,lGotopage
Dim p,parms
If RecordCount Mod PageSize <> 0 Then
pages = 1
else
pages = 0
End If
PageCount=CInt(RecordCount/PageSize + pages)
parms=Array(RecordCount)
lRecordCount = Format(C_RECORDCOUNT,parms)
if CInt(CurrentPage)>1 Then
parms=Array(Pageurl,1)
lFirstpage = Format(C_FIRSTPAGE1,parms)
parms=Array(Pageurl,CInt(CurrentPage)-1)
lPrevpage = Format(C_PREVPAGE1,parms)
Else
lFirstpage=C_FIRSTPAGE2
lPrevpage=C_PREVPAGE2
End If
if CInt(CurrentPage)
lNextpage = Format(C_NEXTPAGE1,parms)
parms=Array(Pageurl,CInt(CurrentPage)+1)
lLastpage = Format(C_LASTPAGE1,parms)
Else
lNextpage=C_NEXTPAGE2
lLastpage=C_LASTPAGE2
End If
parms=Array(CurrentPage,PageCount)
lCurrentpage = Format(C_CURRENTPAGE,parms)
parms=Array(PageSize)
lPagesize = Format(C_PAGESIZE,parms)
parms=Array(Pageurl,CurrentPage)
lGotopage = Format(C_GOTOPAGE,parms)
p=lRecordCount&lFirstpage&lPrevpage&lNextpage&lLastpage&lCurrentpage&lPagesize&lGotopage
Page = p
End Function
End Class
%>
AccHelper.asp
<%
'///
'/// AccHelper 的摘要说明。
'///
Class AccHelper
Public CONN_STRING
'///
'/// 执行ExecuteNonQuery
'///
'/// 连接字符
'/// sql命令
Public Function ExecuteNonQuery(connString,cmdText)
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open connString
objConn.Execute(cmdText)
End Function
'///
'/// 执行ExecuteReader
'///
'/// 连接字符
'/// sql命令
'///
Public Function ExecuteReader(connString,cmdText)
Dim objConn,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open connString
Set objRS = objConn.Execute(cmdText)
Set ExecuteReader = objRS
End Function
'///
'/// 执行Recordset
'///
'/// 连接字符
'/// sql命令
'///
Public Function Recordset(connString,cmdText)
Dim objConn,objRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open connString
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open cmdText,objConn,1,3
Set Recordset = objRS
End Function
Private Sub Class_Initialize()
CONN_STRING = "provider = microsoft.jet.oledb.4.0;data source=" & Server.Mappath("db.mdb")
End Sub
End Class
%>
到此,关于"asp怎么实现简单的ajax留言板"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!
信息
摘要
留言板
学习
命令
字符
内容
更多
上一
首页
帮助
更新
实用
接下来
代码
作者
关键
关键字
字段
客户
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
模特图写真台湾服务器
java软件开发招聘阜新
重庆联想服务器虚拟化建设
名字在数据库中怎么表示
自己开服务器做什么生意好
河北运营软件开发条件
计算机网络技术万定生pdf
上海物联网软件开发公司排行榜
软件开发项目怎样管理
学生网络安全宣传视频小学生
用服务器接业务端口
福禄克网络技术
阿里云linux服务器编译程序
幽灵行动断点连不上ub服务器
10g服务器
村居网络安全宣传活动简报
如何让数据库和网络共享
ark连接好友服务器游戏崩溃
专业数据库管理
博山食品软件开发定制
饥荒联机版开服务器会卡么
网络安全手抄报内容简约
四川前端软件开发哪里好
数据库系统分析和设计报告
类似数据库操作的题目
广东x86视频服务器供应商
网络安全事件笔录提纲
系统软件开发税率
做网络安全解决方案
南昌惠联网络技术有限公司