you're already doing it... and doing it properly... execute a reader, use it to load the datatable, close the reader...
I would make some changes though...
-tgCode:Public Function GetResultSet(ByVal SqlQuery As String) As DataTable 'This Function Returns as table of data based 'on the sql query passed into the function Dim Table As DataTable = nothing Dim Reader As MySqlDataReader Try Dim cmd As New MySqlCommand(SqlQuery, Datacon) Reader = cmd.ExecuteReader If Reader.HasRows Then Table = new DataTable Table.Load(Reader) End If Catch DBError As Exception MessageBox.Show("Error Retrieving Data") End Try If Not Reader.IsClosed Then Reader.Close() return Table




Reply With Quote
