Connecting to a datastore

To connect to a datastore:

  1. Create a connection object consisting of information about the target datastore and protocol.
  2. Supply logon information using a logon step object.
    The number of logon steps required depends on the target database. At a minimum, you must supply an address, a userid, and a password. A server name may also be required.
This code example illustrates the process of connecting to a datastore in the context of inserting multiple rows into the datastore. Because connections and commands are essentially inseparable, it makes little sense to illustrate a database connection alone. The relationship between connection objects and command objects is discussed in
Chapter 3.

      
    {
          TSQLStandardDBProtocolSQLNet15 sqlNet;
          TSQLStandardDataStoreOracle7 oracle7;
          TSQLStandardConnectionHandle dbc(sqlNet, oracle7);
    dbc.LogonStep(1, TSQLLogonStep( TStandardText("t:129.213.80.90:SAMP"), TStandardText("auser"), TStandardText("apassword"))); TSQLCommandHandle insertCmd(dbc.CreateSQLCommand(TStandardText( "INSERT INTO Project VALUES(?, ?)"))); insertCmd.Parameter(2) = TStandardText("Marketing"); for (long empNo = 1; empNo <= 10; empNo++) { insertCmd.Parameter(1) = empNo; insertCmd.Execute(); }


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker