DBConnect

LabWindows/CVI SQL Toolkit 2.3 Help

Edition Date: August 2015

Part Number: 370502D-01

»View Product Info
Download Help (Windows Only)

int DBConnect (char connectionString[]);

Purpose

Opens a connection to a database system to allow execution of SQL statements. Calling DBConnect is equivalent to calling DBNewConnection and then DBOpenConnection.

Note Note  If your program is multithreaded, you must call DBInit before calling DBConnect or DBNewConnection.

Example

Use the following code to connect to CVI Sample tables:

hdbc = DBConnect ("DSN=CVI32_Samples");
...
res_code = DBDisconnect (hdbc);

Parameters

Input
Name Type Description
connectionString char [] Specifies a data source as a detailed connection string containing a series of argument = value statements separated by semicolons.

The following attributes are supported at the ADO level. Any other arguments are passed directly to the provider without any processing by ADO.

Attribute Description
Provider Name of ADO provider to use for the connection. If not specified the connection uses the default ODBC provider.
Data Source Name of the data source to use for the connection, for example a Microsoft Access database registered as an ODBC data source.
User ID User name to use when opening the connection.
Password Password to use when opening the connection.
File Name Provider specific file that contains preset connection information.

Most ODBC data sources support the following attributes. Refer to the driver documentation for each database for additional attributes.

Attribute Description
DSN Name of the ODBC data source to use for the connection. In many cases, DSN is the only parameter you must specify.
DLG When enabled (DLG=1) displays a dialog box that allows user input of connection string information.
UID User ID or name.
PWD Password.
MODIFYSQL Set to 1, support ODBC compliant SQL. Set to 0, support native SQL of the underlying database.

Return Value

Name Type Description
connectionHandle int Database connection handle that identifies the connection and is a parameter to other functions. If the handle is less than or equal to 0, the program could not open the connection.

Note Note  The LabWindows/CVI SQL Toolkit 1.1 and earlier always returned 0 on error. To minimize changes to programs that depend on this behavior, set the compatibility mode to version 1.1 with the following function call:
DBSetBackwardCompatibility(110);

WAS THIS ARTICLE HELPFUL?

Not Helpful