Hello,

I have this method that accepts sqlcommand (string) and FlexGrid, I want to populate the flexGrid with the result of the sql command, as shown below.

Problem is, it gives me an error.


Public Sub FillFlexGrid(ByVal sqlcmd As String, ByVal Flxgrid As VSFlex8U.VSFlexGrid)
Dim tmpTable As DataTable
dim rw as integer = 0
dim cl as integer = 0
Try
con.Open()
Dim dtset As New DataSet
Dim dtad As SqlDataAdapter = New SqlDataAdapter(sqlcmd, con)
dtad.Fill(dtset, "tmpTable")
tmpTable = dtset.Tables("tmpTable")

For Each row As DataRow In tmpTable.Rows
For Each col As DataColumn In tmpTable.Columns
With Flxgrid
.TextMatrix(rw, cl) = row(col)
cl += 1
End With
rw += 1
Next
Next
Catch ex As SqlException
MessageBox.Show(ex.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub



thanks....