ASP 我想知道百度帖吧是什么原理ASP如何实现呢

来源:百度知道 编辑:UC知道 时间:2024/05/16 19:42:37
我看到如果有搜索的字段的贴吧 就进这个吧了 要是没有的话,就自动创建新的贴吧 这个在ASP中怎么才能实现呢`

原理是什么啊

给段演示性代码:
<%
'...数据库连接
tb_name = Request.Form("txtName") '获取用户输入的贴吧名称
if tb_name<>"" then
sql = "SELECT id FROM 百度贴吧 WHERE 贴吧名称='" & tb_name & "'"
Set rs = Conn.Execute(sql)
If Not rs.Eof then '该贴吧已存在
rsClose
connClose
Response.Redirect("百度贴吧?n=" & tb_name) '重定向到该贴吧
Else '如果不存在
Response.Write("您是第一个进入" & tb_name & "的人, 是否创建?") '提示
'..后续代码
'创建之后:
conn.Execute("INSERT INTO 百度贴吧 (贴吧名称) VALUES('" & tb_name & "')" '将该贴吧的名称插入数据库
rsClose
connClose
end if
else '如果输入内容为空
Response.Write("请输入贴吧名称!")
end if

Sub rsClose() '用于关闭,释放RecordSet对象
rs.Close
Set rs = Nothing
End Sub

Sub connClose() '用于关闭,释放Connection对象
conn.Close
Set conn = nothing
End