So my case is that I want to populate a 2d array from two fields in my database.
I've got a problem with assigning an array with a value which is a database field
and the second one is displaying the array in datagrid, i've coded dgv2.Datasource = myArray but it's still returning an error message.
This is my code:
Dim msql As String = "select item_id from detail"
Dim arayT(,) As String
CMD = New MySqlCommand(msql, conn.konek)
Dim res= CMD.ExecuteReader()
For i As Integer = 0 To x - 1
For j = 0 To y - 1
arayT(i, j) = res.GetString("item_id")
Catch ex As Exception
dgv2.DataSource = arayT
hi guys my questions is finally clear, this is the answer to my question
ReDim Preserve arayT(x, y) For i = 0 To (x-1) For j = 0 To (y-1) hasil.Read() arayT(i, j) = hasil("kode_brg") Next j Next i
it turned out that i don't need to use while..
many thanks for Afnan, Neolisk and Emmad that had already helped me to answer my questions. :)