Opens a connection to a data source. Corresponds to the DBConnect action.
Using the DBConnect method establishes the physical connection to a data source. After this action successfully completes, the connection is live and you can issue commands against it and process the results.
App.DBConnect(Name, ServerType, ConnectString)
Newlook Smartclient
Newlook Server
Name - (Object, Required)
A name that you assign to the connection object that represents the connection to the data source. The connection will be referred to by this name in all subsequent DB actions. For example, your Connection name might be "CustDBConnection".
ServerType - (Integer, Required)
The type of data source to which you are connecting. Use one of the pre-defined Server constants.
Connect String - (Input, String, Required)
This parameter consists of semi-colon separated name/value pairs that specify the database or server and all relevant connection properties. The contents of the connection string can vary, depending upon the data source or server that is used for the connection. Each name/pair value is formatted as 'name=value'. For example:'Provider=Microsoft.Jet.OLEDB.4.0;DataSource=@test\crm.mdb'.
A string specifying the database connection details. This parameter consists of semi-colon separated name/value pairs that specify the database and all relevant connection properties. The contents of the connection string can vary, depending upon the data source or server that is used for the connection. For ADO connections, use the Datalink Properties tool in the Database Description window to create the connection string (see tip box below)/server.
Each name/pair value is formatted as so: 'name=value'. Eg.'Provider=Microsoft.Jet.OLEDB.4.0;DataSource=@test\crm.mdb'.
For assistance in creating a database connection string, use the database description window from the Tools menu. This tool can be used to construct the Connection String automatically based on the values entered into the various fields. Copy and paste the resulting connection string from the macro editor into your script, remembering to enclose the string in quotation marks. For more detailed information refer to the topic Using the database description window to create a connection.
The following example connects to and opens an Access database called "crm.mdb" using the MS Jet database driver. VBSCRIPTsConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=@test\crm.mdb;Mode=Share Deny None;Persist Security Info=False"
SampleConnection.Open "SampleRecordset", "Table1", nlDBUseClient, nlDBOpenDynamic, nlDBLockReadOnly, nlDBCmdTable
JSCRIPTvar sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=newlooksdk/newlookSDK.mdb;Persist Security Info=False"; App.DbConnect("SampleConnection", nlDBServerADO, sConnectString); SampleConnection.Open("SampleRecordset", "newlookSDK", nlDBUseServer, nlDBOpenKeyset, nlDBLockReadOnly, nlDBCmdTable);
The following example connects to and opens an Access database called via a Data Source Name (DSN) "MS Access Database" JSCRIPTvar sConnectString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=DSN=MS Access Database;DBQ=newlookSDK/newlookSDK.mdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"; App.DBConnect("Sample Connection", nlDBServerADO, sConnectString); SampleConnection.Open("SampleRecordset", "newlookSDK", nlDBUseServer, nlDBOpenKeyset, nlDBLockReadOnly, nlDBCmdTable);
The following example connects and opens an IBM i database: JSCRIPTvar sConnectString = "Network Address=" + App.GetValue("NetworkAddress") + ";Network Port=447;Use Encryption for Data=False;Host CCSID=37;Mode=ReadWrite|ShareDenyNone;Isolation Level=ReadCommitted;Process Binary as Character=True"; App.DbConnect("SampleConnection", nlDBServerDDM, sConnectString); SampleConnection.Open("SampleRecordset", "QGPL/QAFCTUTDBF(DBFILE1)", 1, 1, 2, 5); |
This method returns an object with a Name property set to the string specified in the Name argument.
Open Method | Disconnect Method | Close Method | Find Method | Move Method | AddNew Method | BeginTrans Method | CancelUpdate Method | CommitTrans Method | Delete Method | RollbackTrans Method | Seek Method | Update Method | ConnectionString property | DB Connection object | Data Access
© 2004-2021 looksoftware. All rights reserved.