首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

update数据,该怎么解决

2012-03-02 
update数据请看我的代码!--#includefile conn.asp --%setconnserver.createobject( adodb.connect

update数据
请看我的代码  

<!--#include   file= "conn.asp "-->
<%
set   conn   =   server.createobject( "adodb.connection ")
set   strconn=server.createobject( "adodb.recordset ")  
strSQL= "select   *   from   CustomerProfile   where   CustomerSerial= "&session( "passport ")& " "
conn.open   strDS1
strconn.open   strSQL,   conn
%>

<head>
<meta   http-equiv= "Content-Language "   content= "zh-cn ">
</head>

<body   topmargin=0   leftmargin=0>
<div   align= "center ">
<table   border= "0 "   width= "90% "   cellspacing= "0 "   cellpadding= "0 "   height=30>
<tr>
<td> </td>
</tr>
</table>
</div>
<form   action=Profileupdate.asp   method=post>
<table   border= "0 "   width= "80% "   cellspacing= "0 "   cellpadding= "0 ">
<tr>
<td   width= "100% "   colspan= "2 ">
<p   style= "line-height:   200%;   margin-left:   150px ">   <b> Customer   Profile </b> </td>
</tr>
<tr>
<td   width= "30% "   align= "right ">
<p   style= "line-height:   200% "> Your   Name: </td>
<td   width= "70% ">
<p   style= "line-height:   200% ">
<input   type= "text "   name= "CustomerName "   value= " <%=strconn( "CustomerName ")%> "     class=input> </td>
</tr>
<tr>
<td   width= "30% "   align= "right ">
<p   style= "line-height:   200% "> Email: </td>
<td   width= "70% ">
<p   style= "line-height:   200% ">
<input   type= "text "   name= "CustomerEmail "   value= " <%=strconn( "CustomerEmail ")%> "     class=input   readonly=yes> </td>
</tr>
<tr>
<td   width= "30% "   align= "right ">
<p   style= "line-height:   200% "> Password: </td>
<td   width= "70% ">
<p   style= "line-height:   200% ">
<input   type= "text "   name= "CustomerPassword "   value= " <%=strconn( "CustomerPassword ")%> "     class=input> </td>
</tr>
<tr>
<td   width= "30% "   align= "right ">
<p   style= "line-height:   200% ">   </td>
<td   width= "70% "> <br>
<p   style= "line-height:   200% ">
<input   type= "submit "   value= "Submit "   name= "submit "   class=submit> </td>
</tr>
</table>
</form>
</body>
<%
conn.close
set   conn=nothing
%>

这个是Profile.asp的页面,下面是profileupdate.asp的页面


<!--#include   file= "conn.asp "-->
<%
if   request.form( "CustomerEmail ")= " "   then   strError   =   "Miss   Email "
if   request.form( "CustomerPassword ")= " "   then   strError   =   "Miss     Password "
strCustomerName=request.form( "CustomerName ")
strpassword=request.form( "CustomerPassword ")
if   strError   =   " "   then
    strOK   =   Request.Form( "Submit ")
                set   conn   =   server.createobject( "adodb.connection ")
                set   strconn=server.createobject( "adodb.recordset ")  
                strSQL= "Update   CustomerProfile   set   CustomerPassword   =   ' "&strpassword& " ' "
                strSQL=strSQL   &   "   CustomerName   =   ' "&strCustomerName& " ' "
                strSQL=strSQL   &   "   where   CustomerSerial= ' "&session( "passport ")& " ' "
                conn.open   strDS1
                strconn.open   strSQL,   conn          
                conn.close
                set   conn=nothing
                     
               
end   if

%> <%if   strOK   <> " "   then%> <font   color= "#FF0000 "> Successful! <br> You   can   click  
<a   href= "Profile.asp "> here </a>   and   get   back   </font>
<%else%>

<br>
<p   style= "line-height:   200%;   margin-left:50px "> <br> <font   color= "#FF0000 "> <%=strError%> </font>
<%end   if%>

可是每次我更新的时候,都提示错误

Microsoft   OLE   DB   Provider   for   ODBC   Drivers   错误   '80040e14 '  

[Microsoft][ODBC   SQL   Server   Driver][SQL   Server]第   1   行:   'CustomerName '   附近有语法错误。  

/sp/User/Profileupdate.asp,行15

可是我不晓得错误到底是什么,请指导,谢谢

[解决办法]
SQL少个逗号吧,试试看
strSQL= "Update CustomerProfile set CustomerPassword = ' "&strpassword& " ', "

热点排行