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

这段代码错在哪里?
function   defaulttext()
dim   bgname  
dim   content
bgname=rs1( "bgname ")
  set   rs1=Server.CreateObject( "ADODB.Recordset ")
sql= "Select   *   from   baogao   "
rs1.open   sql,conn,1,1,&H0000
if   not   rs1.eof   then

if   rs1( "语文 ")=1   then  
                        content=   " <a   href= '/result/yw/ "&bgname& ' "> A </a> "
                        else
                        response.write   "A "
                  end   if
  end   if
return   content

------解决方案--------------------
function defaulttext()
dim bgname
dim content
set conn = CreateObject( "ADODB.Connection ")
conn.open "xxxxxxxxxx "
set rs1=Server.CreateObject( "ADODB.Recordset ")
sql= "Select * from baogao "
rs1.open sql,conn,1,1
if not (rs1.eof and rs1.bof) then
if rs1( "语文 ")=1 then
content= " <a href= '/result/yw/ " & replace(rs1( "bgname "), " ' ", "&apos; ") & " '> A </a> "
else
content= "A "
end if
end if
rs1.close
set rs1 = nothing
conn.close
set conn = nothing
defaulttext = content
end function
------解决方案--------------------
content= " <a href= '/result/yw/ "&bgname& ' "> A </a> "
content= " <a href= '/result/yw/ "&bgname& " '> A </a> "
------解决方案--------------------
function defaulttext()
dim bgname
dim content

set rs1=Server.CreateObject( "ADODB.Recordset ")
sql= "Select * from baogao "
rs1.open sql,conn,1,1,&H0000
if not rs1.eof then
bgname=rs1( "bgname ")
if rs1( "语文 ")=1 then
content= " <a href= '/result/yw/ "&bgname& " '> A </a> "
else
response.write "A "
end if
end if
rs1.close
set rs1=nothing
defaulttext = content
end function

这样测试一下
------解决方案--------------------
function defaulttext()
dim bgname
dim content
set rs1=Server.CreateObject( "ADODB.Recordset ")
sql= "Select * from baogao " '这地方为什么没有where呢?很奇怪,难道楼主可以保证表里只有一条记录?如果有多条记录,下面的rs1(bgname)是个数组阿。
rs1.open sql,conn,1,1 ',&H0000(这地方不知道什么意思,从来没见过这种写法,见笑了)
if not(rs1.eof or rs1.bof) then
if rs1( "语文 ")=1 then '表里的这个 "语文 "字段是什么类型的呀?楼主可以保证一定是数字么?如果字段类型是不是数字类型,但值为数字,那么建议用cint(rs1( "语文 "))转一下再去和数字1比较,否则条件永远不成立的。
bgname=rs1( "bgname ")
content= " <a href= '/result/yw/ "&bgname& ' "> A </a> "
else
content= "A "
end if
defaulttext=content
else