我要从数据集中过滤值 .它包含以零和非零值开头的电话号码。如何从数据集中过滤电话号码(以非零开头)。下面是 vb.net 代码和由此产生的错误。
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'"
错误:你调用的对象是空的。行过滤器行中的错误
最佳答案
在您的 ds1 中有 无表 *reports.renewal_contact_t*。将其更改为
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'"
关于dataset - 从 vb.net 中的数据集中过滤记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12419053/