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

如何判断数据库的表中是否有这个记录
mySql   =   "select   name   from   admin_user   where   name= "   &   request( "name1 ")
set   myRecord   =   Server.CreateObject( "ADODB.Recordset ")
myRecord.Open   mySql,   myConn,2,3       提示这行出错

if   myRecord( "name ").value=request( "name1 ")   then
response.write( " <script       laguage= 'javascript '> window.confirm( '数据表用有相同记录 ')window.location= 'mainFrame_add.asp '; </script> ")  
end   if

------解决方案--------------------
if request( "name1 ") = " " then response.wirte "Name is Empty. " : response.end

mySql = "select name from admin_user where name= ' " & request( "name1 ") & " ' "
------解决方案--------------------
判断数据有无:

if not (myRecord.eof or myRecord.bof) then '表示有此数据.

else '没有此数据时需要处理

end if
------解决方案--------------------
具体出错信息是什么?
不过按你的语句来看,name字段应该是字符串类型的。应该用单引号括起来:
mySql = "select name from admin_user where name= ' " & request( "name1 ") & " ' "