Object reference not set to an instance of an object.

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 114
Reputation: ninjaimp is an unknown quantity at this point 
Solved Threads: 6
ninjaimp ninjaimp is offline Offline
Junior Poster

Object reference not set to an instance of an object.

 
0
  #1
May 12th, 2008
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:

  1. Dim re As String
  2. Dim s As String
  3. Dim i As Integer
  4. Dim TotalRows As Integer
  5.  
  6. TotalRows = dt.Rows.Count
  7.  
  8. s = LCase(txtSearch.Text)
  9.  
  10. lstResults.Items.Clear()
  11.  
  12. For i = 1 To TotalRows
  13.  
  14. re = ds.Tables("CdrData").Rows(i).Item(5)
  15. If InStr(LCase(re), s) Then
  16. lstResults.Items.Add(ds.Tables("CdrData").Rows(i).Item(1))
  17. End If
  18.  
  19. Next


I ust cant see what the problem is?

MAny thanks
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 144
Reputation: sierrainfo is an unknown quantity at this point 
Solved Threads: 9
sierrainfo sierrainfo is offline Offline
Junior Poster

Re: Object reference not set to an instance of an object.

 
0
  #2
May 15th, 2008
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>
Last edited by Ancient Dragon; May 18th, 2008 at 6:50 am. Reason: snipped url
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC