Must you use "Nothing" keyword to initialize a DataSet in VB.Internet?

Well should you set the variable to "Nothing" then you are not initialising a real DataSet object whatsoever - you are just setting the need for the variable to some null reference.

To have an instance or static variable, Nothing would be the default value. For any local variable, in C# there's effectively no default because the compiler does not allow you to make use of a variable before it is certainly designated - if the VB compiler allows you pull off this or otherwise is dependent on compiler configurations. However, whether it does allow you to make use of an unassigned variable, the worthiness is going to be Nothing automatically.

Dim ds as New DataSet

(or, whether it's already defined, ds = New DataSet) ... is all that you should initialise a real DataSet object. It's using the 'New' keyword that produces the item. Afterwards, after it's some DataTables inside it, you are able to obvious them by helping cover their


As Jon states,

Dim ds as Dataset = nothing

... doesn't create a clear case of a DataSet, initialised or else. All it will is define 'ds' like a variable that has to make reference to a clear case of the DataSet class, and clearly sets it to suggest to nothing.

Dim ds as DataSet

.. would attain the same factor. Again, afterwards, after you have used your DataSet,

ds = Nothing

... doesn't reinitialise the DataSet, all it will is placed your variable 'ds' to no more make reference to anything.