在向数据行添加值时,在vb.net中找不到列0.错误

时间:2012-09-14 07:10:44

标签: string datatable vb.net-2010 datarow

有datatable.while为该行添加值时出现错误。每次我在数据表中为该数据行添加一个新值时使用for循环。

my code
=======
dt3 = ds1.Tables(0)
                For Each q In dt3.Rows
                    chkphone = q("PHONE").ToString
                    chkdphone = Regex.Replace(chkphone, "[^\d]", "")

                    'MessageBox.Show(chkdphone)


                    If (chkdphone.Length = 10) Then
                        Dim NTN As DataRow = dt4.NewRow
                        NTN(0) = chkdphone.ToString
                        dt4.Rows.Add(NTN)

                    ElseIf (chkdphone.Length >= 10) Then
                        rsltstring = chkdphone.Substring(chkdphone.Length - 10, 10)

                        Dim NTN1 As DataRow = dt4.NewRow
                        NTN1(0) = rsltstring.ToString
                        dt4.Rows.Add(NTN1)
                    End If
                Next

when i debug the code in first itself am getting error in the line NTN(0) = chkdphone.ToString



error :  could not find column 0

0 个答案:

没有答案