Execute Stored Procedures and Views in VB.NET

This article explains that how we can execute stored procedures and views.You can execute stored procedures and views using three execute methods of SqlCommand object.
  • 3877

You can execute stored procedures and views using three execute methods (ExecuteNonQuery, ExecuteReader, and ExecuteScalar) methods of SqlCommand object. Before you call execute method of SqlCommand to execute a stored procedure, you need to set SqlCommand.CommandType property to CommandType.StoredProcedure and SqlCommand.CommandText as stored procedure name.

Private cmd As SqlCommand = New SqlCommand()
Private cmd.Connection = con
Private cmd.CommandType = CommandType.StoredProcedure
Private cmd.CommandText = "CustOrderHist"

You can also use stored procedure and views in your SELECT statements to retrieve data from stored procedures and views. Instead of a database table name, you use stored procedure or view name.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.