VB Code:
Dim mycmd As New SqlCommand("Select ItemID,ItemName,Quantity,unitPrice,Total,Remarks From Invoice_Details where InvID = " & txtInvID.Text & "", MyConn)
MyConn.Open()
Dim myReader As SqlDataReader
myReader = mycmd.ExecuteReader
Do While myReader.Read
Dim x As Integer
For x = 0 To Flex1.Rows - 1
Flex1.set_TextMatrix(x, 1, myReader.GetValue(0))
Flex1.set_TextMatrix(x, 2, myReader.GetString(1))
Flex1.set_TextMatrix(x, 3, myReader.GetValue(2))
Flex1.set_TextMatrix(x, 4, myReader.GetValue(3))
Flex1.set_TextMatrix(x, 5, myReader.GetValue(4))
Flex1.set_TextMatrix(x, 6, myReader.GetString(5))
Next
Loop
myReader.Close()
MyConn.Close()