将值插入现有数据集的新数据集中

时间:2012-09-11 09:36:15

标签: for-loop dataset vb.net-2010

使用vb.net.Having数据集包含列名作为phone .it包含一组电话号码。我想为每个电话号码添加0并将其存储在另一个数据集中。

我的代码

cmd = New OracleCommand("select substr(PHONE,-10)as 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 = ds.Clone()
For Each q In ds.Tables(0).Rows
   phone = z + q("PHONE").ToString
   For Each q1 In ds1.Tables(0).Rows
      q1("PHONE") = phone
   Next
Next

我的问题是没有在ds1中获取值。

请帮我纠正。

1 个答案:

答案 0 :(得分:1)

你应该试试这个

cmd = New OracleCommand("select substr(PHONE,-10)as 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 = ds.Copy()

For Each q In ds1.Tables(0).Rows
    q("PHONE") = "0" + q("PHONE").ToString
Next