Storing SQL Statements in the Database

Throughout this chapter, we have discussed how to write SQL queries. One way to use SQL is to create a query in a string variable and then pass it to the database using ADO or some other data access technology. However, an even better method is to store the SQL queries in the database itself, and just call the stored query using ADO. Queries stored on a SQL server are called stored procedures and can be executed like any other SQL query. (In Microsoft Access, all queries are stored queries, because you have to create a new query object to even key in a SQL statement.) Stored queries act similarly to functions or subroutines in Visual Basic, and can include input and output parameters. Using stored queries ...

Get Special Edition Using Microsoft® Visual Basic® .NET 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.