Am getting data from database and store in dataset.dataset contains list of phone numbers.
i want to find out the length of each and every phone numbers. if it is length ten means add it in one datatable. Or length greater than 10 means get the 10 char from the right side of the phone number and stored it on the same datatable.Here is my code.when i debug the code i get only 8000 some thing rows.but originally the dataset contains 40,700 row values. after the
datatable reaches 8000 rows am getting error
my code
-------
ada.Fill(ds, "reports.renewal_contact_t ")
ds.Tables(0).DefaultView.RowFilter = " PHONE NOT like'0'"
dt = ds.Tables(0)
For Each q In dt.Rows
chkphone = q("PHONE").ToString
chkdphone = Regex.Replace(chkphone, "[^\d]", "")
'MessageBox.Show(chkdphone)
If (chkdphone.Length = 10) Then
Dim anyRow As DataRow = dt2.NewRow
anyRow(0) = chkphone.ToString
dt2.Rows.Add(anyRow)
ElseIf (chkdphone.Length >= 10) Then
rsltstring = chkdphone.Substring(chkdphone.Length, -10)
Dim anyrow1 As DataRow = dt2.NewRow
anyrow1(0) = rsltstring.ToString
dt2.Rows.Add(anyrow1)
Else
End If
Next
new_ds.Tables.Add(dt2)
ComboBox1.DataSource = new_ds.Tables(0)
ComboBox1.DisplayMember = "PHONE"
Error
-----
length cant be less than zero parameter name length
You can’t use a negative length in the
Substringmethod. Subtract ten from the length to get the starting point of the string that you want:As you want the rest of the string from that point, the second parameter is actually not needed: