如何读取一个记录中连续多个字段的值?

请问如何读取一个记录中连续多个字段的值,同时可以判断字断是否为空,读出不为空的字段?
---------------------------------------------------------------

sql="selcet* ..."

然后用isnull 函数来判断
---------------------------------------------------------------

a=rs("fields1")
b=rs("fields2")
c=rs("fields3")
if a="" then
...
end if
.....
---------------------------------------------------------------

set rs=server.createobject("adodb.recordset")
rs.open....
count=rs.fields.count
for i=x to y
if i>count-1 then exit for
fld=rs(i)
if isnull(fld) or trim(fld)="" then
.....
end if
next
---------------------------------------------------------------

for i=0 to sql.fields.count
if not isnull(sql.fields(i).value) then
response.write sql.fields(i).value & "

1<br/>

"
else
response.write "

1<br/>

"
end if
next
这里只能判断字段是否为null,如果你记录中的所有字段为字符型可以换条件为sql.fiels(i).value=""
---------------------------------------------------------------

set Rs = ADODB.RecordSet
sql = "select * from table"
length=5
for i=0 to length
if not isnull(Rs.Fields(i).value) then
response.write Rs.Fields(i).Name.value & ":"&Rs.Fields(i).value & "

1<br/>

"
else
response.write "

1<br/>

"
end if
next

---------------------------------------------------------------

同意楼上
---------------------------------------------------------------

for i=0 to sql.fields.count
if not (IsNull(sql.fields(i).value) and IsEmpty(sql.fields(i).value)) then
response.write sql.fields(i).value & "

1<br/>

"
else
response.write "

1<br/>

"
end if
next

---------------------------------------------------------------

strsql="select * from table"
set rs=server.creatobject("ADOBD.RecordSet")
rs.open strsql,conn,1,1

do while not rs.eof
for i=1 to rs.fields.count
if trim(rs(i))<>"" then
response.write rs(i).name
response.write rs(i)
next
rs.movenext
loop

---------------------------------------------------------------

上面如果不可以用trim(rs(i))来判断也请isnull(rs(i))进行判断

Published At
Categories with Web编程
Tagged with
comments powered by Disqus