Tim Maxey .NET Technology Blog & Resources

VB CreateDataset

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


Feedback

No comments posted yet.


Post a comment





 

Please add 8 and 1 and type the answer here: