You now know what a SqlDataAdapter is and what it can do for you, so let’s examine how to create and use one.
When you create a SqlDataAdapter, you generally want to set its SelectCommand property to a valid SqlCommand object. The following code sample sets the SelectCommand for a new SqlDataAdapter:
Dim strConn, strSQL As String strConn = "Data Source=.\SQLExpress;" & _ "Initial Catalog=Northwind;Integrated Security=True;" strSQL = "SELECT CustomerID, CompanyName FROM Customers" Dim cn As New SqlConnection(strConn) Dim cmd As New SqlCommand(strSQL, cn) Dim da As New SqlDataAdapter() da.SelectCommand = cmd
string strConn, strSQL; strConn = @"Data Source=.\SQLExpress;" ...