Tim Maxey .NET Technology Blog & Resources
This function is passed the string connection for VB.NET
Public Function CreateDataSet(ByVal strSQL As String, ByVal strSQL_Connection As String) As Data.DataSet
Dim scnnNW As New System.Data.SqlClient.SqlConnection(strSQL_Connection)
' A SqlCommand object is used to execute the SQL commands.
Dim scmd As New System.Data.SqlClient.SqlCommand(strSQL, scnnNW)
' A SqlDataAdapter uses the SqlCommand object to fill a DataSet.
Dim sda As New System.Data.SqlClient.SqlDataAdapter(scmd)
' Create and Fill a new DataSet.
Dim ds As New Data.DataSet
sda.Fill(ds)
scnnNW.Close()
scnnNW.Dispose()
Return ds
End Function