asp中添加记录语句有问题么?

来源:百度知道 编辑:UC知道 时间:2024/07/01 04:18:16
idnum=Request.Form("idnum")
strTitle = Request.Form("title")
strTitle = Trim(strTitle)
strTitle = replace(strTitle," ,"," ")

strTitle = server.HTMLEncode(strTitle)
'strTitle = replace(strTitle,"<","<")
'strTitle = replace(strTitle,">",">")

strflag_attention = Request.Form("flag_attention")
if strflag_attention = "on" then
flag_attention = 1
else
flag_attention = 0
end if

strText = Request.Form("detail")
strText = replace(strText,"'","''")

'strText = server.HTMLEncode(strText)
'strText = replace(strText,chr(13)&chr(10),"<br>")
'strText = replace(strText," "," ")

strText = replace(strText,"<","<")
strTex

如果这样写容易出错,可以用
Rs.Addnew
Rs("字段名") = "值"
.......
Rs.Update
来处理

肯定是有问题的,
SQL = "SELECT * from board "
set rs = server.CreateObject("adodb.recordset")
rs.Open sql,conn ‘这里语句不完整。

if isnull(rs(0)) then
idnum=1
else
idnum=rs(0)+1
end if
rs.close
这里获得的idnum每次都是一样的。
rs.open sql,conn,1,3
sql = "insert into board(idnum,title,flag_attention,detail) values (" & idnum & ",'" & strTitle & "'," & strflag_attention & ",'" & strText & "')"
这两句顺序反了。或者使用conn.execute sql
反正问题多了去了。