关于ASP中SQL的UPDATE问题请教
又要麻烦大家了,我有个ASP文件,是向SQL存数据的,添加新的数据没有问题,就是再UPDATE时候总是有错误,看了半天也没看出什么错误,现把代码全部粘帖出来,想请大家帮忙看看!!<!--#include File="../ConnDB.asp"-->
<!--#include file="isAdmin.asp"-->
<html>
<head>
<title>编辑客户信息</title>
</head>
<body>
<%
Function changechr(str)
changechr = Replace(str," "," ")
changechr = Replace(changechr,Chr(13),"<br>")
End Function
Dim GName
Dim StrAction
'得到动作参数,如果为add则表示添加新商品,如果为update则表示更改商品
StrAction = Request.QueryString("action")
'取得商品题目和内容和提交人用户名
CName = Trim(Request("co_name"))
CName = Replace(CName ,"'","‘")
GName = Trim(Request("name"))
GName = Replace(GName ,"'","‘")
rqtContent = changechr(Request("Content")) '替换函数
rqtContent = Replace(rqtContent,"'","‘") '替换内容中的单引号
Set rs = Server.CreateObject("ADODB.RECORDSET")
If StrAction="add" Then
'在数据库表Goods中插入新商品信息
sql="Select * from LedCompany"
rs.Open sql,Conn,1,3
rs.AddNew
rs("FirstTypeId") = CInt(Request.Form("firsttypeid"))
rs("SecondTypeId") = CInt(Request.Form("secondtypeid"))
rs("ThirdTypeId") = CInt(Request.Form("thirdtypeid"))
rs("Co_Name")= CName
rs("Sn_Number")= Request("number")
rs("Co_Info") = CInt(Request.Form("Co_Info"))
rs("Posttime")=now()
rs("Web_Address") = Request("webadress")
rs("Address") = Request("adress")
rs("ImageFile") = request("upimage")
rs("Name")= GName
rs("Mobile")= Request("mobile")
rs("Email")=Request("email")
rs("Telephone")=Request("telephone")
rs("Fax")=Request("fax")
rs("Content")=rqtContent
rs.Update
Else
'更改此商品信息
id = Request.QueryString("id")
sql = "Update LedCompany Set FirstTypeId="&CInt(Request.Form("FirstTypeId"))&",SecSecondTypeId"))&",ThirdTypeId="&CInt(Request.Form("ThirdTypeId"))&",Co_Name='"&CName&"',Sn_Number='"&Request("number")&"',Co_Info="&CInt(Request.Form("Co_Info"))&",Posttime='"&now()&"'" &_
",Web_Adress="&Request("webadress")&",Adress="&Request("adress")&",Name='"&GName&"',Mobile='"&Request("mobile")&"',Email='"&Request("email")&"',Telephone='"&Request("telephone")&"',Fax='"&Request("fax")&"'" &_
",Content='"&rqtContent&"' Where id="&CInt(id)
Conn.Execute(sql)
End If
Set rs = Nothing
response.write "<h3>客户成功保存</h3>"
%>
</body>
<script language="javascript">
// 刷新父级窗口,延迟此关闭
opener.location.reload();
setTimeout("window.close()",600);
</script>
</html>