2

I''d like to know what will happen to dataset when its table is being returned within its using statement. Example a function with code as follow:

using tmpDataSet = MySqlHelper.ExecuteDataSet(_connString, strSQL)
    if tmpDataSet is not nothing andalso tmpDataSet.Tables.Count > 0 then
        return tmpDataSet.Tables(0)
    end if
end using

I want to have a function which will provide me requested datatable, and will dispose the datatable whenever I am done playing with it. I just wonder, whether the dataset will be disposed properly while its table is being returned, as I do not want this will cause memory leak.

Buzz
  • 321
  • 2
  • 3
  • 20
  • 2
    I suggest reading [Should I Dispose() Datasets and DataTables?](http://stackoverflow.com/questions/913228/should-i-dispose-dataset-and-datatable) – Steve Nov 08 '16 at 07:42

0 Answers0