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

添加记录出问题?
代码如下  

<%   response.buffer=true   %>
<!--#include   file= "connection.asp "-->
<%
new_id=session( "student ")
new_title=trim(request.Form( "mgstitle "))
new_face=trim(request.Form( "mgsface "))
new_body=request.Form( "mgsbody ")  

if(len(new_body)> 250)   then
Response.Write   " <script> window.alert( '留言内容不能超过250个字符! ');window.location= 'mgs.asp '; </script> "
end   if


        dim   strSql,svalues
        strSql= "insert   into   mgs(stu_id,mgs_title,mgs_date,mgs_body,mgs_pic)   values( ' "&new_id& " ', ' "&new_title& " ', ' "&date& " ', ' "&new_body& " ', ' "&new_face& " ') "
db.execute(strSql)




'Sql= "insert   into   mgs(stu_id "
        'svalues= "values( ' "&   new_id   &   " ' "
        'Sql=Sql   &   ",mgs_title "
        'svalues=svalues   &   ", ' "   &   new_title   &   " ' "
        'Sql=Sql   &   ",mgs_body "
        'svalues=svalues   &   ", ' "   &   new_body   &   " ' "
'Sql=Sql   &   ",mgs_date "
'svalues=svalues   &   ", ' "   &   date   &   " ' "
        'Sql=Sql   &   ",mgs_pic "
        'svalues=svalues   &   ", ' "   &   new_face   &   " ' "
        'Sql=Sql   &   ") "   &   svalues   &   ") "   */
       
Response.Write   " <script> window.alert( '谢谢您的留言! ');window.location= 'mgs.asp '; </script> "
db.close
%>


出现错误
错误类型:
Microsoft   OLE   DB   Provider   for   ODBC   Drivers   (0x80040E07)
[Microsoft][ODBC   Microsoft   Access   Driver]   标准表达式中数据类型不匹配。
/rrrrr/addmgs.asp,   第   16   行

该怎么解决啊
谢谢


------解决方案--------------------
遇到这种情况,我的经验是,一个字段一个字段的试
例如strSql= "insert into mgs(stu_id) values( "&new_id) "
如果添加成功了,就再加一个字段试,以此类推
如果第一个都不成功都就看看字段名有没有错,或有没有其他问题