# Remove row in db result set

**URL:** <https://forum.xojo.com/t/remove-row-in-db-result-set/24214>\
**Category:** General\
**Created:** [May 13, 2015, 9:51am UTC](https://forum.xojo.com/t/remove-row-in-db-result-set/24214 "2015-05-13T09:51:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![changwon\_lee](https://forum.xojo.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@changwon\_lee](https://forum.xojo.com/u/changwon_lee)\
**Post date:** [May 13, 2015, 9:51am UTC](https://forum.xojo.com/t/remove-row-in-db-result-set/24214/1 "2015-05-13T09:51:13Z")

</div>

I have a result set of database query and want to remove the row having NULL value in the 4th column.  
Below code doesn’t work.  
Can you let me know how to do that?

While Not rs.EOF

```
If rs.IdxField(4).StringValue = "" Then 
  rs.MoveNext
Else 
  dataList.AddRow("")
End If

For i As Integer = 0 To rs.FieldCount-1
  dataList.Cell(dataList.LastIndex, i) = rs.IdxField(i+1).StringValue
Next
rs.MoveNext

```

Wend

Thanks.

---

<div class="post-metadata">

**Author:** ![Don\_Lyttle](https://forum.xojo.com/user_avatar/forum.xojo.com/don_lyttle/32/324_2.png) [@Don\_Lyttle](https://forum.xojo.com/u/Don_Lyttle)\
**Post date:** [May 13, 2015, 11:13am UTC](https://forum.xojo.com/t/remove-row-in-db-result-set/24214/2 "2015-05-13T11:13:44Z")

</div>

> [@186828:@changwon lee](#):
>
> If rs.IdxField(4).StringValue = “” Then

For starters, don’t know for sure which database you’re using (I’m guessing SQLite), but in my SQL Server database code I use the following to check for NULL:

```auto
if rs.Field("NotesData").Value.IsNull THEN
```

There are a lot of posts in this forum that deal with the differences between NULL, Nil, and “”. It’s an education all unto itself! I know I ran into problems originally assuming that “” and NULL were the same thing. Also, check out DatabaseField in the Language Reference to see the difference between using DatabaseField.StringValue [which is a Property(as String)] versus DatabaseField.Value [which is a Property(as Variant)]

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [May 13, 2015, 11:28am UTC](https://forum.xojo.com/t/remove-row-in-db-result-set/24214/3 "2015-05-13T11:28:03Z")

</div>

Why not alter the driving SQL statement to not read those records to begin with?

```auto
AND NOTEFIELD IS NOT NULL
```

Personally I never refer to database fields by index, I ALWAYS use NAME

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:45pm UTC](https://forum.xojo.com/t/remove-row-in-db-result-set/24214/4 "2020-10-29T17:45:11Z")

</div>


