DatabaseOpenConnection
Opens a connection to the database specified as the parameter.
Syntax
bool DatabaseOpenConnection (string strConnectionString)
Parameters
- strConnectionString
- Type: String
Returns
True, if the connection opens. Otherwise, False.Level
All, but generally used at the Batch level.Details
Opens a connection to the database specified as the parameter.
A rule containing this action can apply to any object of the Document Hierarchy (DCO), but it is most often used at the batch level.
This action connects to the database using a 64-bit connection. The proper 64-bit client interface must be available for the target database.
DatabaseOpenConnection("@APPVAR(*/exportdb:cs)")Note: This action must
come before any other ExportToDatabase actions. This example uses smart parameters to obtain the
connection string from the application service where the custom connection string key
exportdb has been created in the Custom Values tab. It
provides a single location for the connection string and security for passwords. If necessary,
multiple custom variables can be created to connect to different databases.
Note: If the
action is establishing a connection with an Oracle database, or an SQL Server database using SQL
Server Authentication, be sure to expand the DSN parameter by adding the correct Provider, user ID
and Password.
For example:- Access:
-
DatabaseOpenConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Datacap\TravelDocs\TravelDocsExport.mdb;Persist Security Info=False;")Access databases are not supported in a production environment.
- Oracle:
-
DatabaseOpenConnection("PROVIDER=OraOLEDB.Oracle;Data Source=1040Look;ID=Admin;Password=Admin;") - SQL Server:
-
DatabaseOpenConnection("PROVIDER=ODBCMSSQL;DSN=1040Look;CATALOG=;DBNTA=;UID=Admin;PWD=Admin;") - DB2:
-
Provider=IBMDADB2;Data Source=MYDB2SOURCE;UID=user;PWD=password
Note: Although the examples show the full connection string, it is recommended that a smart
parameter is used to obtain the connection string from the application service, as shown in the
first example, to provide password security and application portability.
See also
DatabaseCloseConnection