日期:2014-05-17  浏览次数:21221 次

用asp update...set修改数据库问题,高手帮忙看看
<%  
name=request.form( "name ")
sex=request.form( "sex ")
tel=request.form( "tel ")
id=request.QueryString( "Uid ")
set   conn   =   server.createobject( "adodb.connection ")
connstr= "DRIVER={Microsoft   Access   Driver   (*.mdb)};   DBQ= "   &   server.mappath( "data.mdb ")
conn.Open   connstr
sqlstmt   =   "update   2   set   name= ' "&name& " ',sex= ' "&sex& " ',tel= ' "&tel& " '   where   id= ' "&id& " ' "
Set   rs   =   Server.CreateObject( "ADODB.Recordset ")
conn.execute(sqlstmt)
rs.update
%>  
 
提示
Microsoft   OLE   DB   Provider   for   ODBC   Drivers   (0x80040E07)
[Microsoft][ODBC   Microsoft   Access   Driver]   标准表达式中数据类型不匹配。
/合同/UserModify-VB.asp,   第   14   行
14行是conn.execute(sqlstmt)
请帮看看哪里错了


------解决方案--------------------
sqlstmt = "update 2 set name= ' "&name& " ',sex= ' "&sex& " ',tel= ' "&tel& " ' where id= ' "&id& " ' "

ID是int型的吧

改成

sqlstmt = "update 2 set name= ' "&name& " ',sex= ' "&sex& " ',tel= ' "&tel& " ' where id= "&id