Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 9

Accessing Data With the Prepare/Execute Model

The Prepare/Execute model assumes the following steps:
  1. You make an on-the-fly request to the provider, instructing it to compile your request.

  2. The provider compiles your request.

  3. The provider executes the compiled request.

  4. The provider returns the result to you.

  5. When you make the same request in the future during this session, the provider repeats steps 3 and 4, using the already compiled statement.

You can make a request using the Prepare/Execute model by using a Command object in the following steps:

STEP BY STEP
9.1 Making a Request Using the Prepare/Execute Model

  1. Set the Command object's Prepared property to True.

  2. Set the Command object's CommandType property to adCmdText if you are executing a SQL statement, or adCmdTable if the request is just a table name (or skip this step and use the Options parameter in step 4).

  3. Set the Command object's CommandText property to the text of the SQL statement that you want to execute (or skip this step and pass the SQL statement as an argument to the Execute method in the following step).

  4. Call the Command object's Execute method. If you did not set the CommandType property in step 2, pass the appropriate value as the CommandType argument. If you did not set the CommandText property in step 3, pass the SQL statement as the Options argument (the third argument) to the Execute method.

The Prepared property of a Command object makes the difference between the Prepare/Execute and the Execute Direct models. When the Prepared property is set to True, the provider compiles the SQL statement to a temporary stored procedure before running it. The provider persists this temporary stored procedure until the Command object is changed or destroyed

NOTE - Stored Procedures and Parameters: The information under the section "Using Stored Procedures" contains more information on how to program with stored procedures in the ADO object model. Also see the section "Using the Parameters Collection to Access Parameters for Stored Procedures" for more information on how to work with a Command object's Parameters collection


  

<< Previous | Content | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved