日期:2014-05-18  浏览次数:20755 次

为什么我总是插不进数据啊?
如题。
如果我不插入from字段,就没问题,就是将:
      String   sql_send= "insert   into   SMS(to,from,title,content,ptime)   values( ' "+to+ " ', ' "+from+ " ', ' "+title+ " ', ' "+content+ " ', ' "+ptime+ " ') ";
改成:
      String   sql_send= "insert   into   SMS(to,title,content,ptime)   values( ' "+to+ " ', ' "+title+ " ', ' "+content+ " ', ' "+ptime+ " ') ";
就OK

但一旦插from字段,就报错:
数据库更新出错:[Microsoft][ODBC   Microsoft   Access   Driver]   INSERT   INTO   语句的语法错误。

究竟是怎么回事啊?究竟是我数据库设计错了还是其他问题啊?
大侠们快帮帮我啊,快愁死啦……


====数据库部分====
[SMS]         短信表
id               自动编号(主键)
to               收信者(文本,50)
from           发信者(文本,50)
title         标题(文本,200)
content     内容(备注)
ptime         发信时间(时间/日期)

====表单部分====
<input   name= "to "   type= "hidden "     id= "to "   value= "管理员 "/>

<input   name= "from "   type= "text "   class= "colorblur "   id= "from "   value= " <%=Sess_tName%> "   readonly= "true "size= "56 "/>

注:变量Sess_tName是已定义的session值

<input   name= "title "   type= "text "   class= "colorblur "   id= "title "   value= "发短信测试标题 "   size= "60 "   maxlength= "40 "   />

<textarea   name= "content "   cols= "60 "   rows= "4 "   class= "colorblur "   id= "content "> 发短信测试内容 </textarea>


=====处理页面部分====
<%  
      request.setCharacterEncoding( "gb2312 ");
      String   to=new   String(request.getParameter( "to ").getBytes( "ISO-8859-1 "));
      String   from=new   String(request.getParameter( "from ").getBytes( "ISO-8859-1 "));
      String   title=new   String(request.getParameter( "title ").getBytes( "ISO-8859-1 "));
      String   content=new   String(request.getParameter( "content ").getBytes( "ISO-8859-1 "));
      String   ptime=(new   java.util.Date()).toLocaleString();  
     
      String   sql_send= "insert   into   SMS(to,from,title,content,ptime)   values( ' "+to+ " ', ' "+from+ " ', ' "+title+ " ', ' "+content+ " ', ' "+ptime+ " ') ";
      out.print(sql_send);

      try
      {
            stmt.executeUpdate(sql_send);
    out.print( " <script> alert( '发送信息成功!请耐心等待回复。 ');document.location.href= 'msg_r.jsp '; </script> ");
}catch(Exception   e)
          {

    //out.print( " <s