Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter records from the dataset in vb.net

I want to filter values from a dataset. It contain phone numbers starting with zero and non zero values. How can I filter a phone number (start with non zero no) from the dataset. Below is the vb.net code and the resulting error.

cmd = New OracleCommand("select  PHONE from  reports.renewal_contact_t where run_date=to_date('" + TextBox1.Text + "','mm/dd/yyyy') and  EXP_DATE =to_date('" + TextBox2.Text + "','mm/dd/yyyy') and  region not in('TNP')", cn)
ada = New OracleDataAdapter(cmd)
ada.Fill(ds, "reports.renewal_contact_t ")
Dim ds1 As New DataSet
ds1.Tables("reports.renewal_contact_t").DefaultView.RowFilter = "PHONE NOT like'0'"

Error: Object reference not set to an instance of an object. error in rowfilter line

like image 681
vps Avatar asked Oct 24 '25 14:10

vps


1 Answers

Within your ds1 there is no table *reports.renewal_contact_t*. Change it to

cmd = New OracleCommand("select  PHONE from  reports.renewal_contact_t where run_date=to_date('" + TextBox1.Text + "','mm/dd/yyyy') and  EXP_DATE =to_date('" + TextBox2.Text + "','mm/dd/yyyy') and  region not in('TNP')", cn)
ada = New OracleDataAdapter(cmd)
ada.Fill(ds, "reports.renewal_contact_t")
' no need for a new dataset - as you fill ds (and not ds1)!!
ds.Tables("reports.renewal_contact_t").DefaultView.RowFilter = "PHONE NOT like'0'"
like image 163
Pilgerstorfer Franz Avatar answered Oct 27 '25 00:10

Pilgerstorfer Franz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!