Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an application where I need to get data values from one datatable to another datatable. Code that I use to add rows after select is

VB
For i = 0 To PSBill.Tables("Section").Rows.Count
   Section = PSBill.Tables("Section").Select("type='ICD'")(i).ItemArray(1).ToString
   SelectedData.Rows.Add(Section)
Next


But I get an error saying Index was outside the bounds of the array. My Rows.Count value is 30

Is there something that i am missing?
Posted

try

For i = 0 To PSBill.Tables("Section").Rows.Count-1
 
Share this answer
 
Comments
Vamshi Krishna Naidu 4-Nov-12 4:36am    
Working Now. Thanks
Bala Selvanayagam 4-Nov-12 6:46am    
My pleasure
VB
For i = 0 To PSBill.Tables("Section").Rows.Count

This goes from 0 to RecordCount -> 1 extra as things start from 0 index.

Change to:
VB
For i = 0 To PSBill.Tables("Section").Rows.Count-1
 
Share this answer
 
Comments
Vamshi Krishna Naidu 4-Nov-12 4:36am    
Working Now. Thanks
Sandeep Mewara 4-Nov-12 4:37am    
Welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900