ResultSet rs=st.executeQuery("select ID from news where title="+title+);

显示错误:[Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 1

原因:参数没传递过去

 在数据库中 字符串 要用单引号 字符串变量用   "-----------'"+变量名+"'-----------" 

修改如下:

  ResultSet rs=st.executeQuery("select ID from news where title='"+title+"'");

 

今天有发现了同一个错误:就再写写吧:

st.executeUpdate("insert into news (ID,title,content,author)values("+id+",'"+title+"','"+content+"','"+author+"')");

因为id在数据库中是int型所以不需 '   '   

而titile content author 都是字符类型 所以需要 '    '  

posted on 2013-05-18 23:23  小影~~~  阅读(3063)  评论(0编辑  收藏  举报