The SqlClient Namespace and Stored Procedures

Now that you've seen how to call stored procedures using the OleDb namespace, it's interesting to compare the same tasks using the SqlClient namespace. Remember that when you use the SqlClient namespace, you're using code that's written to interact specifically with SQL Server, and this code can take advantage of specific SQL Server features. The code you'll see, EmpAddSqlClient, works almost identically to the EmpAddOleDb procedure you saw earlier, but there are some subtle differences.

Listing 15.6 shows the entire procedure.

Listing 15.6. Using the SqlClient Namespace to Call a Stored Procedure
 Private Sub EmpAddSqlClient() Dim cmd As SqlClient.SqlCommand Dim strSQL As String Dim strConn As String ...

Get ASP.NET Developer's JumpStart now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.