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

刚学SQL 求SQL添加记录语句 整句语法
<!--#include   file= "conn.asp "-->   '据库调用   这段正确无误.
<%
sql   =   "insert   Into   新闻   (news_title,news_classid)   Values(news_title,news_classid) "  
conn.execute(sql)
Response.Redirect   "newseord.asp?news_classid= "&news_classid& " "
%>

整个记录添加就这样了!可是根本不管用!一添加程序就直接   执行   Response.Redirect   "newseord.asp?news_classid= "&news_classid& " "
因为这是类别新闻显示   当求不到   记录news_classid   的时候就显示出错!
问题主要是   程序没有执行   insert   Into   新闻……   导致的结果吧!所以现在我要求一段完整的   SQL   添加记录语法!准确无误.

表名   news_title和news_classid

谢谢!

------解决方案--------------------
sql = "insert Into 新闻 (news_title,news_classid) Values(news_title,news_classid) "

请问你插入的news_title new_classid值是多少?如果已经把值赋给了news_title news_classid

那么就改成

sql = "insert Into 新闻 (news_title,news_classid) Values( " '&news_title& " ', ' "&news_classid& " ') "
------解决方案--------------------
在conn.asp中有没有on error resume next ?
如果有的话去掉,看看出什么错误
------解决方案--------------------
insert Into 新闻 (news_title,news_classid) Values(news_title,news_classid)
--------------------------------------
把这句放到查询分析器里执行一下,把后面的news_title和news_classid换成具体的
数值。测试一下,看在查询分析器里能不能成功。