这段代码为什么不能保存到sql数据库里?

netboy821215 2004-04-07 09:20:05
<!--#include file="dbpath/dbpath.asp"-->
<!--#include file="function/char.inc"-->
<%
sub getInput()
sSubject=request.form("dSubject")
sMemo=request.form("dMemo")
sGq=request.form("dgq")
sName=request.form("dname")
sAddress=request.form("daddress")
sCode=request.form("dcode")
stypeid=request.form("lbmc")
sgs=request.form("dgs")
end sub

dim rs

dim sSubject
dim sMemo
dim sGq
dim sName
dim sAddress
dim sCode
dim stypeid
dim sgs

dim errorMsg
dim foundError

getInput()
saveData()
if foundError=false then
response.redirect "manage.asp"
else
call showerrors()
end if
set rs=nothing
conn.close
set conn=nothing



sub saveData()
dim InsertCursor
Set InsertCursor = Server.CreateObject("ADODB.Recordset")

InsertCursor.Open "select * from gq",conn,1,3
InsertCursor.addnew
InsertCursor("name") =htmlencode(sName)
InsertCursor("address") =htmlencode(sAddress)
InsertCursor("code") =htmlencode(sCode)
InsertCursor("subject") =htmlencode(sSubject)
InsertCursor("memo") =htmlencode(sMemo)
InsertCursor("gs") =htmlencode(sgs)
InsertCursor("gq") =sGq
InsertCursor("lbid") =stypeid
InsertCursor("gqdate") =cstr(date())
InsertCursor("gqtime") =cstr(time())
InsertCursor.Update
InsertCursor.close
if err>0 then
err.clear
foundError=true
ErrorMsg="<li>Êý ¾Ý ¿â ²Ù ×÷ ʧ °Ü !</li>"
else
foundError=false
end if
end sub

sub showErrors()
%>
...全文
68 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ttkkyy 2004-04-07
  • 打赏
  • 举报
回复
你确定一下是否取到了传过来得值
插不进去值是新增了记录但没有值,还是记录没有增加
GoodyeahApple 2004-04-07
  • 打赏
  • 举报
回复
将错误捕捉的部分先注释掉,看看是那错了。
netboy821215 2004-04-07
  • 打赏
  • 举报
回复
ttkkyy 不行啊 我换过来了
netboy821215 2004-04-07
  • 打赏
  • 举报
回复
没有人回应 郁闷!!~~~~~~~~
ttkkyy 2004-04-07
  • 打赏
  • 举报
回复
你把取得数据的程序不要写为过程试一下

<!--#include file="dbpath/dbpath.asp"-->
<!--#include file="function/char.inc"-->
<%


dim rs

dim sSubject
dim sMemo
dim sGq
dim sName
dim sAddress
dim sCode
dim stypeid
dim sgs

dim errorMsg
dim foundError

sSubject=request.form("dSubject")
sMemo=request.form("dMemo")
sGq=request.form("dgq")
sName=request.form("dname")
sAddress=request.form("daddress")
sCode=request.form("dcode")
stypeid=request.form("lbmc")
sgs=request.form("dgs")


saveData()
if foundError=false then
response.redirect "manage.asp"
else
call showerrors()
end if
set rs=nothing
conn.close
set conn=nothing



sub saveData()
dim InsertCursor
Set InsertCursor = Server.CreateObject("ADODB.Recordset")

InsertCursor.Open "select * from gq",conn,1,3
InsertCursor.addnew
InsertCursor("name") =htmlencode(sName)
InsertCursor("address") =htmlencode(sAddress)
InsertCursor("code") =htmlencode(sCode)
InsertCursor("subject") =htmlencode(sSubject)
InsertCursor("memo") =htmlencode(sMemo)
InsertCursor("gs") =htmlencode(sgs)
InsertCursor("gq") =sGq
InsertCursor("lbid") =stypeid
InsertCursor("gqdate") =cstr(date())
InsertCursor("gqtime") =cstr(time())
InsertCursor.Update
InsertCursor.close
if err>0 then
err.clear
foundError=true
ErrorMsg="<li>Êý ¾Ý ¿â ²Ù ×÷ ʧ °Ü !</li>"
else
foundError=false
end if
end sub

sub showErrors()
%>
netboy821215 2004-04-07
  • 打赏
  • 举报
回复
继续等待……
netboy821215 2004-04-07
  • 打赏
  • 举报
回复
没有提示错误~添加数据不能入库 我都不知道什么原因。继续等待……
qzriso 2004-04-07
  • 打赏
  • 举报
回复
有没有提示什么错误?

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧