0

Hi

I have a dataset which is popultaed with data from a text file, which in turn then populates a datagrid. This all works fine.

What im trying to do is search within the dataset based on a value input into a text box.

But everytime i do the search i keep gettign the error:

Object reference not set to an instance of an object.

The code i am using for the search is this:

Dim re As String
        Dim s As String
        Dim i As Integer
        Dim TotalRows As Integer

        TotalRows = dt.Rows.Count

        s = LCase(txtSearch.Text)

        lstResults.Items.Clear()

        For i = 1 To TotalRows

            re = ds.Tables("CdrData").Rows(i).Item(5)
            If InStr(LCase(re), s) Then
                lstResults.Items.Add(ds.Tables("CdrData").Rows(i).Item(1))
            End If

        Next

I ust cant see what the problem is?

MAny thanks

2
Contributors
1
Reply
8
Views
9 Years
Discussion Span
Last Post by sierrainfo
0

This error occurs when 'New' has not been used to initialize an object. But there could be another possibility..Comment this line and see..
lstResults.Items.Clear()

Regards
Sunil Punjabi
<URL snipped>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.