1. Member
Join Date
Dec 1969
Posts
34

Hi !<BR><BR>i have to loop thru a database table and i have to write <BR>the names of all the fields of that table except the FIRST field.<BR><BR>the code for all the fields is :<BR>...<BR>for each x in rs.fields<BR> Response.Write(x.name) <BR> next <BR> rs.close<BR>...<BR>But it displays the first field name which i dont need ..<BR><BR>Can anyone help plz??<BR><BR>Thanks

2. Senior Member
Join Date
Dec 1969
Posts
2,225

for each x in rs.fields<BR>if x = 0 Then<BR>&#039; do nothing<BR>Else<BR>Response.Write(x.name)<BR>End If<BR>next <BR>rs.close<BR>

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Maybe so, but a wrong answer!

if x = 0 Then <BR>????<BR><BR>WHAT? If x is a text field, then it will *NEVER* be = to zero, even if it&#039;s blank. And certainly any NULL field will never equal zero.<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Easier than you think...

Do NOT use FOR EACH and you&#039;ve got it.<BR><BR>For fldnum = 1 To RS.Fields.Count-1<BR> Response.Write RS.Fields(fldnum).Name <BR>Next<BR><BR>The fields are numbered starting at zero, so you just start at 1 and presto.<BR><BR>I agree with Chris that this isn&#039;t advanced, though. Just the tiniest bit of logic would have done the job if you&#039;d thought about it (even not knowing about the RS.Field.Count thing):<BR><BR>afterFirst = False<BR>For Each x In RS.Fields<BR> If afterFirst Then ResponseWrite x.Name<BR> afterFirst = True<BR>Next<BR><BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•