c# - Select and updating data from datatable -
i select data datatable, using following code,but throws exception not familiar with.
"index outside bounds of array."
tblrooms.select(idroom = 4)
value of idroom in thetblroom don't know why causes error.
foreach (datarow dr in tblroomcart.rows) { datarow drroom = tblrooms.select("idroom =" + dr["idroom"])[0];//here error in line }
as exception says,index out of bounds,you reading first element (with index 0) there no elements in collection.
same this:
int[] array = new int[0]; int x = array[0];//you exception here
add if statement make sure there @ least 1 element,like:
int[] array = new int[0]; if (array.length > 0) { int x = array[0]; }
Comments
Post a Comment