新手提问:sql与asp的问题,等ing 出现这种错误是因为你的sql语句有问题而导致的!!在此之前加一句:Response.Write(sql)然后屏幕掉该句'conn.execute(sql)将该sql语句打出来,到“查询分析器”上执行一下,看是什么问题!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 查询分析器的结果是这样的:[Microsoft][ODBC SQL Server Driver]语法错误或访问冲突是数据源的问题吗? <%@ Language = "VBScript" %><!-- #Include file="..\include\adovbs.inc" --><!-- #Include file="..\include\cod_ado.inc" --><% strTitle = Request.Form("title") strTitle = Trim(strTitle) strTitle = replace(strTitle,"'","''") strTitle = server.HTMLEncode(strTitle) 'strTitle = replace(strTitle,"<","<") 'strTitle = replace(strTitle,">",">") strflag_attention = Request.Form("flag_attention") if strflag_attention = "on" then flag_attention = 1 else flag_attention = 0 end if strText = Request.Form("detail") strText = replace(strText,"'","''") 'strText = server.HTMLEncode(strText) 'strText = replace(strText,chr(13)&chr(10),"<br>") 'strText = replace(strText," "," ") strText = replace(strText,"<","<") strText = replace(strText,">",">") dim objCnn,rs strDSN = "dsn=newdata;uid=;pwd=;" strSQL = "SELECT MAX(idnum) from board" cod_AdoOpen objCnn,rs,strDSN,strSQL if isnull(rs(0)) then idnum=1 else idnum=rs(0)+1 end if rs.close strSQL = "insert into board(IDNUM,title,flag_attention,detail) values (" &idnum &",'" &strTitle & "'," & flag_attention & ",'" & strText & "')" 'Response.Write strSql objCnn.Execute(strSQL) 提示是这一句的问题! objCnn.close set objCnn = nothing response.redirect "bulletin.asp" %> 报这个错误应该是SQL里登陆用户的问题,看看你的程序,你连接到SQL的用户名和密码怎么都是空呀?你连接到SQL的用户对board这个表要有权限才行呀! 因为设了匿名用户所以用户名和密码为空这里IDnum是自动编号,加了标记后就没有问题了 多半是你的SQL语句有问题看看数据类型是否和表里的相匹配 数据库服务器的CPU经常100%,请问如何解决 索引视图全文索引的一些问题 SQL里如何把日期时间类型的数值,只取时间部分,请问怎么实现?在线等待 请教一个触发器的写法 导入远程SQL的问题 请问:DateAdd函数中,第一个参数的数据类型是什么? 请教一个简单的语法问题,关于case 【索引疑惑】 俺学习数据库的一点感受 win2000下,DEPHI+SQL SERVER写的ADO程序,想在局域网内的98下运行,该怎样连接数据库? 试过将SQL SERVER 7 的数据库备份文件还原到SQL SERVER 2OOO 的大虾请进! 高分悬赏,请问使用存储过程的优点
<!-- #Include file="..\include\adovbs.inc" -->
<!-- #Include file="..\include\cod_ado.inc" -->
<%
strTitle = Request.Form("title")
strTitle = Trim(strTitle)
strTitle = replace(strTitle,"'","''")
strTitle = server.HTMLEncode(strTitle)
'strTitle = replace(strTitle,"<","<")
'strTitle = replace(strTitle,">",">") strflag_attention = Request.Form("flag_attention")
if strflag_attention = "on" then
flag_attention = 1
else
flag_attention = 0
end if
strText = Request.Form("detail")
strText = replace(strText,"'","''")
'strText = server.HTMLEncode(strText)
'strText = replace(strText,chr(13)&chr(10),"<br>")
'strText = replace(strText," "," ")
strText = replace(strText,"<","<")
strText = replace(strText,">",">")
dim objCnn,rs
strDSN = "dsn=newdata;uid=;pwd=;"
strSQL = "SELECT MAX(idnum) from board"
cod_AdoOpen objCnn,rs,strDSN,strSQL if isnull(rs(0)) then
idnum=1
else
idnum=rs(0)+1
end if
rs.close
strSQL = "insert into board(IDNUM,title,flag_attention,detail) values (" &idnum &",'" &strTitle & "'," & flag_attention & ",'" & strText & "')"
'Response.Write strSql
objCnn.Execute(strSQL) 提示是这一句的问题! objCnn.close
set objCnn = nothing
response.redirect "bulletin.asp"
%>
这里IDnum是自动编号,加了标记后就没有问题了
看看数据类型是否和表里的相匹配