Results 1 to 2 of 2

Thread: How Can I Fill FlexGrid with DataReader

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    31

    How Can I Fill FlexGrid with DataReader

    I Used This Code To Fill FlexGrid
    But The Result Is Fill All FlexGrid Rows by The First Row On The DataReader
    It May be Loop Statment Error

    Please Help
    Code:
     Dim mycmd As New SqlCommand("Select ItemID,ItemName,Quantity,unitPrice,Total,Remarks From Pur_Invoice_Details where InvID = " & txtInvID.Text & "", MyConn)
            MyConn.Open()
    
            Dim myReader As SqlDataReader
            myReader = mycmd.ExecuteReader
    
            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
    
            End While
    
            myReader.Close()
            MyConn.Close()

  2. #2
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    I am not sure why you are using that for... next loop.
    I think you just have to incriment the value of x by 1 at end of the while ... end while loop.

    is set_textmatrix method automatically incriment the rows of the grid? i don't know. i havn't used it.
    when in doubt, win the trick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width