Logging In to SQL Server

The SqlLogin% function allocates a SQL Server login record and returns a value that serves as the identifier for that login record. The login record is made up of a set of attributes that are initially assigned default values. Although you cannot manipulate the login record directly, you can use DB-Library for Visual Basic functions to specify a username, a password, an application name, and several optional attributes. For example:

A Visual Basic form is a good tool for obtaining the required login information from the user. The following program fragment uses SqlLogin% to allocate a login record:

'Get a login record and set login attributes.
Login% = SqlLogin%()
Result% = SqlSetLUser%(Login%, "loginid")
Result% = SqlSetLPwd%(Login%, "passwd")
Result% = SqlSetLApp%(Login%, "example")