barcode generator in vb.net codeproject Accessing SQL Data from Your Host Program in Software

Maker Code 3/9 in Software Accessing SQL Data from Your Host Program

Accessing SQL Data from Your Host Program
Code 39 Scanner In None
Using Barcode Control SDK for Software Control to generate, create, read, scan barcode image in Software applications.
Code 3 Of 9 Generation In None
Using Barcode printer for Software Control to generate, create ANSI/AIM Code 39 image in Software applications.
Allocating Handles
Scanning Code 3 Of 9 In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
Code 3 Of 9 Maker In C#
Using Barcode drawer for .NET framework Control to generate, create Code 3/9 image in .NET framework applications.
The first step that you must take when accessing a database through a CLI interface is to establish the necessary allocation handles. An allocation handle is an object returned by the SQL database when a resource is allocated. The handle is used by the host program to access the database. You must establish three types of allocation handles in your host program in order to access SQL data from within that program:
Code 3/9 Creator In VS .NET
Using Barcode maker for ASP.NET Control to generate, create Code 39 Extended image in ASP.NET applications.
USS Code 39 Drawer In Visual Studio .NET
Using Barcode drawer for VS .NET Control to generate, create Code39 image in .NET applications.
Environment handle Establishes the environment in which all CLI functions are called and provides a context in which to establish one or more connection handles. Connection handle Establishes a connection context to a specific SQL database. The connection handle must be established within the context of the environment handle. A connection handle doesn t actually connect to the database. It merely provides the context to make that connection possible. Once a connection handle has been established, you must use the context of that handle to make the actual connection to the database. Statement handle Establishes a context in which SQL statements can be executed. Any statement invoked through the CLI must be executed within the context of a statement handle, and the statement handle must be defined within the context of a connection handle.
Make USS Code 39 In VB.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create Code 3/9 image in VS .NET applications.
Generating UPC-A Supplement 5 In None
Using Barcode encoder for Software Control to generate, create UPC A image in Software applications.
To better understand how allocation handles operate, let s take a look at Figure 17-4. As you can see in the figure, two connection handles are allocated within an environment handle,
Barcode Maker In None
Using Barcode drawer for Software Control to generate, create bar code image in Software applications.
Code 39 Creation In None
Using Barcode printer for Software Control to generate, create Code 3/9 image in Software applications.
Environment handle Connection handle Connection handle
Drawing Barcode In None
Using Barcode creation for Software Control to generate, create barcode image in Software applications.
Drawing Code 128C In None
Using Barcode generation for Software Control to generate, create Code-128 image in Software applications.
Statement handle SQL statement SQL statement SQL statement SQL statement
Drawing Planet In None
Using Barcode drawer for Software Control to generate, create USPS Confirm Service Barcode image in Software applications.
Data Matrix ECC200 Recognizer In VB.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
Statement handle SQL statement SQL statement SQL statement SQL statement
ECC200 Drawer In None
Using Barcode drawer for Microsoft Word Control to generate, create DataMatrix image in Microsoft Word applications.
Creating Bar Code In Java
Using Barcode encoder for Android Control to generate, create barcode image in Android applications.
Connection to database 1
Making Barcode In None
Using Barcode creation for Font Control to generate, create barcode image in Font applications.
Scanning Barcode In VB.NET
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET framework applications.
Connection to database 2
Generate UPC-A Supplement 5 In None
Using Barcode drawer for Office Word Control to generate, create UPC-A Supplement 5 image in Microsoft Word applications.
ECC200 Creator In Java
Using Barcode printer for Java Control to generate, create DataMatrix image in Java applications.
Figure 17-4
Establishing allocation handles
SQL: A Beginner s Guide
and one statement handle is allocated within each connection handle. Each SQL statement is executed within the context of a statement handle.
Establishing an Environment Handle
To establish an environment handle in which to support database access, you can use the AllocHandle( ) function, which requires three arguments. The first argument (SQL_HANDLE_ ENV) specifies the type of handle (environment) that is being allocated. The second argument (SQL_NULL_HANDLE) indicates that the environment handle does not depend on any existing handle. The third argument is a host variable that identifies the environment handle. When a host variable is used in this context, it is preceded by an ampersand (&).
NOTE
Host variables are declared according to the conventions of the host language. In addition, the host program might contain other elements that support CLI functionality. For example, a C program might require special include files necessary to interact with the CLI API. Also be aware that language libraries can vary from vendor to vendor; for instance, there are several known inconsistencies between the C libraries provided by Microsoft and Borland. In addition, the host program might contain special errorhandling functions that can monitor the success or failure of a CLI routine call. For information about language-specific elements that should be included in your host program, be sure to check the documentation for the specific language, CLI API, and SQL implementation.
Now that we ve reviewed the individual elements necessary to establish an environment handle, let s take a look at the AllocHandle( ) function as it would be included in your C program:
SQLAllocHandle ( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv );
The first thing you ll notice is that the AllocHandle function is preceded by the SQL prefix. In C programs, the SQL prefix is added to all CLI functions. The prefix can vary according to the host language. You ll also notice in this statement that the three arguments are enclosed in parentheses and separated by commas. In addition, the host variable that identifies the handle is preceded by an ampersand.
Establishing a Connection Handle
Once you ve established your environment handle, you can establish one or more connection handles within the context of that environment. To do so, you will again use the AllocHandle( ) function, along with three arguments. The first argument (SQL_HANDLE_DBC) specifies the type of handle (connection) that is being allocated. The second argument identifies the environment in which the connection is being established. (This is the host variable identified when you established the environment handle.) The third argument is a host variable that identifies the connection handle. Again, it is preceded by an ampersand, as shown in the following function statement:
SQLAllocHandle ( SQL_HANDLE_DBC, henv, &hdbc );
17:
Copyright © OnBarcode.com . All rights reserved.