《茶花女》:asp后台管理向sqlserver中添加记录

来源:百度文库 编辑:高考问答 时间:2024/04/29 03:44:35
现在需要在后台管理系统页面中向sqlserver数据库插入一条记录,主要有两个页面:add.asp和add_save.asp。

add.asp中提交表单到add_save.asp,表单项为name="neirong"。

add_save.asp的代码主要是:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="articlechar.inc"-->
<% if request.form("neirong")=""then
response.Write("错误提示:未输入内容!")
response.End()
end if
%>
<%
neirong=request.form("neirong")
set rs=server.CreateObject("adodb.recordset")
sql="select * from gonggao where id is null"
rs.open sql,conn,1,3
rs.addnew
rs("内容")=neirong
rs.update
rs.close
set rs=nothing
conn.close
%>

在sqlserver数据库中有两个字段,一个是“id”,一个是中文字段“内容”。

现在无法向数据库中插入数据,执行以上两个页面也不报错。

请指教!
谢谢!

改用Insert语句;把CODEPAGE属性去掉

你把id is null用括号括起来试试
sql="select * from gonggao where (id is null)"

你的这种方法我没用过,还是用insert into gonggao(字段) valuse(值) 这种方法吧