set conn=Server.Createobject("ADODB.Connection")
set rs=Server.Createobject("ADODB.Recordset")
conn.open dbConnection
conn.cursorlocation=3
rs.activeconnection=conn
SQL= "Select * from tbl_1 where cd_code='"&cd1&"' and status is null "
rs.Open SQL ,,1,3
countfields = rs.Fields.Count
while not rs.EOF
name=rs("name")
have1=have1+1
rs.movenext
wend
rs.close
conn.close
set rs = nothing
set conn = nothing
if have1=0 then
set conn=Server.Createobject("ADODB.Connection")
set rs=Server.Createobject("ADODB.Recordset")
conn.open dbConnection
conn.cursorlocation=3
rs.activeconnection=conn
SQL= "Select * from tbl_2 where cd_code='"&cd1&"' and status is null "
rs.Open SQL ,,1,3
countfields = rs.Fields.Count
while not rs.EOF
name=rs("name")
rs.movenext
wend
rs.close
conn.close
set rs = nothing
set conn = nothing