Please some one help me. I have a datarow which is a selection of a few rows from a datatable using the Select method of a datable . Now I want to diplay this roys in a variable, basically an array, ho do I go about this. My code is shown below. The error I get is "Object reference not set to an instance of an object."
Please someone help me.
Private
Sub Show_Order_Datails() Dim i As Integer = 0 Dim j As Integer = 0 Dim OrderID_From_Orderstable As Integer Dim rowSelected_from_OrderDetails() As System.Data.DataRow Dim StrExpression As String Dim count As Integer = 0 'Gets the ORDERID fromthe Orders tableOrderID_From_Orderstable = _
CInt(myOrdersDataTable.Rows(myOrdersRowPosition) _("ORDERID").ToString())StrExpression = "OrderID = " & OrderID_From_Orderstable
'Selects all details of the Order gotten from the Orders table from the Orders detail tablerowSelected_from_OrderDetails = myOrderDetailsDataTable.Select(StrExpression)
'Getting to know the nuber of rows selectedcount = rowSelected_from_OrderDetails.Length
Dim r As System.Data.DataRow Dim c As System.Data.DataColumn For Each r In rowSelected_from_OrderDetails For Each c In r.Table.Columns If j < 3 ThenOrderdetails_array(i)(j) = r(c)
j = j + 1
End If Next ci = i + 1
Next rtxtNameRow1.Text = Orderdetails_array(2)(2)
End SubThe Orderdetails_array(i)(j) is declared as publicPlease help me

Datarow
EvanMinger
Hang on u have a point I need to try something out
Chaehorim
But I'll tell u this I got around it by putting the selected rows in a Temp table I created on the fly.
So I can access the values easily.
so each time I select new rows I have to delete the Values in this temp table b4 putting in the new rows.
This I suppose is bad programming practice, if it doesn't delete everything in the table, I will be working on a wrong data thats my fear.
Telmo Sampaio
The lone that raises the exception is the:
Orderdetails_array(i)(j) = r(c)
misogidave
Can you post details about how you set up myOrdersDataTable and myOrderDetailsDataTable Also, what line of code throws the exception
--
~Alazel
Alazel Acheson
Software Developer
Microsoft SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
plenderj
Can you check the size of Orderdetails_arry()() If it is empty, Orderdetails_arry(i)(j) will fire.
BruceSwierc
Aparrel,
Glad to know you have a work around. From your explaination, the selected rows DataSet returned are correct, but assigning them to the public array fires exception. Looks like the public array has something wrong.
Thanks,
Kevin