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

一小段代码. 总出错,是不是因为字符的类型引起的?该怎么解决呢
<!--#include   file= "conn.asp "-->

<%

%>
<%
if   request.QueryString( "action ")= "re "   then
set   rs=server.CreateObject( "adodb.recordset ")
sql   =   "select   *   from   pic   where   sj= "&request.Form( "sj ")
rs.open   sql,conn,1,1
response.Write(rs( "aname "))
end   if  
%>
<form   name= "form1 "   method= "post "   action= "test.asp?action=re ">
    <label>
    <input   name= "sj "   type= "text "   id= "sj ">
    </label>
    <label>
    <input   type= "submit "   name= "Submit "   value= "提交 ">
    </label>
</form>


为什么总是提示
至少一个参数没有被指定值

就是sql语句那行

所有的字段,我数据库表pic中都有的
不过sj是字符型的,和这个有关系吗?
该怎么解决呢.谢谢先咯.

------解决方案--------------------
试试这样
sql = "select * from pic where sj= ' "&request.Form( "sj ")& " ' "
------解决方案--------------------
不尽是LS这样啊
也可能那是个空值
一进入那个页面时


------解决方案--------------------
SQL语句判断一下,request.Form( "sj ")是否为空
------解决方案--------------------
if len(request.form( "sj "))> 0 then
.......
------解决方案--------------------
conn 对象还没有连接数据库
set conn=server.createobject( "adodb.connection ")
conn.open openstr '连接字符串