ALP NOSC Connection
NOSC SConnection class (progID: newObjects.odbc.SConnection) implements core functions of the NOSC. It is the only object that must be created and initialized before accessing the DB. SConnection class takes care about connecting to the data source and direct execution of SQL statements.

Recordsets working with a particular DB connection are created using the SConnection.GetRecordset method. SConnection object initializes the created recordset and after creation it requires only call of its Open method.

Sample creation and initialization:

VBScript:

Dim Conn,boolSuccess
Set Conn = Server.CreateObject("newObjects.odbc.SConnection")
boolSuccess = Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & ServerMapPath("mydb.mdb"))

JScript:

var Conn, boolSuccess;
Conn = Server.CreateObject("newObjects.odbc.SConnection");
boolSuccess = Conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" + ServerMapPath("mydb.mdb"));

Members:

method.gif (107 bytes)Open variable = object.Open(connectString [, options])
VARIANT_BOOL Open(
    [in] BSTR bstrConnectionString, 
    [in, optional] VARIANT varOptions);
Establishes connection to a data source as specified in the connectString. Additional options can be specified:

dbcOpenExclusive = 0x0001
dbcOpenReadOnly = 0x0002
dbcOpenCursorLib = 0x0004 (default if nothing is specified)
dbcOpenNoODBCDialog = 0x0008 (strongly recommended - denies showing of ODBC dialog if the connection string fails)
dbcOpenForceOdbcDialog = 0x0010 (forces the ODBC dialog)

Method returns true/false on success/error. Check errCode and errDescription properties for details

method.gif (107 bytes)Close object.Close()
void Close();
Closes the connection to the data source. All created recordset are no longer functional.
method.gif (107 bytes)BeginTrans variable = object.BeginTrans()
VARIANT_BOOL BeginTrans();
Begins transaction. Returns boolean result indicating the success/failure.
method.gif (107 bytes)CommitTrans variable = object.CommitTrans()
VARIANT_BOOL CommitTrans();
Commits the transaction started with the BeginTrans method. Returns boolean result indicating success/failure.
method.gif (107 bytes)Rollback variable = object.Rollback()
VARIANT_BOOL Rollback();
Rollback/cancel the started with the BeginTrans method transaction. Returns boolean result indicating success/failure.
method.gif (107 bytes)ExecuteSQL variable = object.ExecuteSQL(sql_string)
long ExecuteSQL([in] BSTR bstrSQL);
Exectutes the passed SQL statement and returns status code. Return result of 0 means success, non zero indicates an error. Check errCode and errDescription properties for details.
method.gif (107 bytes)GetRecordset variable = object.GetRecordset()
ISODBCRecordset* GetRecordset();
Creates new recordset object that uses the connection established by this Connection object.
prop_r.GIF (130 bytes)connectString variable = object.connectString
[propget] BSTR connectString();
Read only property that returns the connection string used - the string used in the Open method.
prop_r.GIF (130 bytes)connected variable = object.connected
[propget] VARIANT_BOOL connected();
Read only property returning boolean result indicating if the Connection object is connected to a data source.
prop_r.GIF (130 bytes)errCode variable = object.errCode
[propget] long errCode();
Read only property. Returns error code long value. The property returns meaningful value only after failure reported by some method such as Open, BeginTrans, CommitTrans, Rollback. Error codes depend on the DB provider and are non zero.
prop_r.GIF (130 bytes)errDescription variable = object.errDescription
[propget] BSTR errDescription();
Read only property. Returns textual error description. In most cases it is generated by the provider or the ODBC itself. Meaningful only after failure reported by the Open, BeginTrans, CommitTrans, Rollback methods.
newObjects Copyright 2001-2006 newObjects [ ]