Connect and Disconnect

The classes generated by Data Access Builder help you access and manipulate information in one or more database tables. Before working with the data in an application, you must connect to the databases that your classes use. To do this, you must specify the database name (set the database name in either the code, as shown below, or in the mapping's properties notebook). Then connect, passing in user ID and password parameters if they are needed. You can also do this in one step, passing in the database name, user name, and password to the connect method.

The following sample code shows how to connect to the desired database:

theDeptDatastore.setDatastoreName (datastoreName);
theDeptDatastore.connect (userid, password);

or:

theDeptDatastore.connect (datastoreName, userid, password);

After connecting, specify settings for the datastore, such as whether it automatically commits transactions. In the following code, the database is set so that it does not automatically commit transactions:

theDeptDatastore.enableAutoCommit(false);

To disconnect from the database, run the following command:

theDeptDatastore.disconnect();



Commit and Rollback


Connection Considerations
Data Access Class Library and Generated Code Reference