Once the application has been initialized, your application interacts with SQL Server by opening one or more SQL Server connections with the appropriate user login information. Your application uses the connection to send Transact-SQL statements to SQL Server and to receive the results of those statements from SQL Server.
To open a SQL Server connection, use the SqlLogin% and SqlOpen% functions. DB-Library for Visual Basic also offers a function called SqlOpenConnection%, which provides a convenient method for logging in to SQL Server and opening a connection in one step. It combines the work of several lower-level functions into a single function, reducing the amount of code needed to log in a user and open a connection.
The following sections describe how to use SqlLogin% and SqlOpen% and provide examples for each function. For an example of how the utility function SqlOpenConnection% is used, refer to the QUERY sample application. This sample application logs in and opens a connection by calling the routine LoginToServer, which in turn calls SqlOpenConnection%. LoginToServer is defined separately in the VBSQLGEN.BAS common code module.