类型不匹配: '[string: select * from course ]'
asp吧
全部回复
仅看楼主
level 1
CKJ丶VaLuE 楼主
<%
Set conn=Server.CreateObject("ADODB.Connection")
DBPath=Server.MapPath("db1.mdb")
conn.Open"provider=microsoft.jet.oledb.4.0;data source="&DBPath
dim kcname,id
kcname=request.form("s1")
set rs=server.createobject("adodb.recordset")
sql="select cid from Course where ctitle=*"+kcname+"*"
rs.open sql,conn,1,1
id=rs("cid")
set rs=server.createobject("adodb.recordset")
sql="select * from Courseware where cid=*"+id+"*"
rs.open sql,conn,1,1
%>
sql="select * from Courseware where cid=*"+id+"*"过不去
我试过转换成整型也不去,数据库中cid的设置的属性是数值。。
2014年11月04日 12点11分 1
level 5
SQL语法错误,将前后的星号都删除:
sql="select * from Courseware where cid="+id
如果提供公共访问,注意安全问题
2014年11月04日 14点11分 2
这个还是过不去 我原来的打错了,是: sql="select * from Courseware where cid=*"id"*" 还是提示的是 类型不匹配: *[string: "select * from Course"]* 会不会是数据库或者其他地方的原因
2014年11月05日 02点11分
不好意思把.net和asp弄混了,应该是sql="select * from Courseware where cid="&id
2014年11月06日 09点11分
回复 啄木鸟工作室8 :搞定了 谢谢~~
2014年11月06日 12点11分
回复 CKJ丶VaLuE :不客气[呵呵]
2014年11月06日 13点11分
level 1
CKJ丶VaLuE 楼主
原来的语句打错了,我用的是: sql="select * from Courseware where cid=‘“id*""
2014年11月05日 02点11分 3
level 12
[狂汗]
首先你要确定你的 cid 是字符串型还是数值型,实际上一般来讲 id 一般常用都是整型,sql 中,数值型的值不能用引号括起来的。只有字符串才需要使用引号括起来。
而且,你的这个语句写的也不对,即使你的 cid 是字符串型,拼接SQL语句的时候
sql="select * from Courseware where cid=‘“id*"" 也不该是这样。
sql="select * from Courseware where cid=‘“ & id &“‘” 正确的SQL拼接应该是这样,其实在ASP环境中,就是字符串的拼接。应该使用 & 符号
2014年11月05日 04点11分 4
1