中科大先研院校车:帮个忙修改一下ASP程序

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 06:17:00
<%
if request.querystring("action")="add" then
laccess=Request.Form("laccess")
username=Request.Form("username")
email=Request.Form("email")
qq=Request.Form("qq")
address=Request.Form("Address")
home=Request.Form("home")
face=Request.Form("face")
title=Request.Form("title")
head=Request.Form("head")
ip=Request.Form("ip")
content=Request.Form("f3_content")
action="ture"
if username="" then
error1="用户不能为空<BR>"
action="false"
end if
if title="" then
error1=error1&"标题不能为空<BR>"
action="false"
end if

if content="" then
error1=error1&"内容不能为空<BR>"
action="false"
end if
if len("content")>total then
error1=error1&"内容超过了"&total&"的限制"
action="false"
end if
if action="false" then

response.redirect("?action=error&error1="&error1&"")
else
strSql = "insert into guestbook (laccess,username,head,ip,email, home,face,occation,qq,title,content) Values ('"
strSql = StrSQl & laccess & "','"
strSql = StrSQl & username & "','"
strSql = StrSQl & head & "','"
strSql = StrSQl & ip & "','"
strSql = StrSQl & email & "','"
strSql = StrSQl & home & "', '"
strSql = StrSQl & face & "', '"
strSql = StrSQl & address & "', '"
strSql = StrSQl & qq & "', '"
strSql = StrSQl & title & "', '"

strSql = StrSQl & content & "')"
conn.Exec (strSQl) (系统提示这一行错误)
response.redirect"index.asp"

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
[Microsoft][ODBC Microsoft Access Driver]非法的精确度数值
/25175/write.asp, 第 53 行

response.end

end if
elseif request.querystring("action")="" then
%>
也可以直接联系我QQ:373289119(请注名百度)

察看数据库中字段数据类型和ASP程序中生成的变量的类型是否一致,可能要用Cint()、Cstr()之类的函数转换一下吧。

还有一点不是很明白:

为什么要用insert写的这么复杂呢?用recordset怎样呢?

set rs=server.createobject("adodb.recordset")
rs.open "select * from guestbook",conn,2,3
rs.addnew
rs("laccess")=laccess '一个字段一个值,是不是要明了一点呢?
...
rs.update
rs.close
set rs=nothing
response.redirect ("index.asp")
..

好好检查一下你数据库的字段和从网页接收到数值之间是不是不一致,错误的类型显示就是字段的类型和值的问题