8.6. Use Parameters in a SQL Command or Stored Procedure
Problem
You need to set the arguments of a stored procedure or use parameters in a SQL query to improve flexibility.
Solution
Create parameter objects appropriate to the type of command object you intend to execute. Configure the parameter objects' data types, values, and directions and add them to the command object's parameter collection using the DbCommand.Parameters.Add method.
How It Works
All command objects support the use of parameters, so you can do the following:
Set the arguments of stored procedures.
Receive stored procedure return values.
Substitute values into SQL queries at runtime.
All parameter objects inherit the MustInherit System.Data.Common.DbParameter class, which implements ...
Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.