Creating an Object


How to create a connection object and connect to your back-end database.

The SQL::Connection Object

The first object you will need when using AlphaDAO is the connection object. The connection object allows you to connect to your back-end database. The first connection object method that you will need to use is its .Open() method. To connect to a back-end database, you must provide a connection string. The connection string tells AlphaDAO how to find and open your database. For example, the following code creates a connection object and then connects to the Microsoft Access alphasports.mdb database.

  1. Type this in the Interactive window:

    dim conn as SQL::Connection
  2. Right click to open the Create SQL Connection String dialog.

  3. Leave the Connection Type list set to "Access".

  4. Click the 'open folder' icon in the File Name control to navigate to and select the AlphaSports.MDB file in the c:\program files\a5v8\mdbfiles\ directory.

  5. Click Test Connection. This should display a dialog box that tells you the connection succeeded.

  6. Click OK to return to the Interactive window. The code should look like this.

    dim conn as SQL::Connection"{A5API=Access,FileName='C:\Program Files\a5v8\MDBFiles\Alphasports.mdb',UserName='Admin'}")

It is very important that you close your connections at your end of your scripts. If your script repeatedly opens connections and does not close them, you will run out of resources. To close an open connection, you use the connection object's .Close() method. Let's close the open connection now. Type this in the Interactive window:


See Also