Difference between revisions of "SQLCONNECT()"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
Line 12: | Line 12: | ||
==Syntax== | ==Syntax== | ||
SQLCONNECT([<nStatementHandle>]) | SQLCONNECT([<nStatementHandle>]) | ||
− | SQLCONNECT([<cConnectionName> | <cDataSourceName> [, <cUserID> [, <cPassword>]] | + | |
− | [, <lShared]]) | + | SQLCONNECT([<cConnectionName> | <cDataSourceName> [, <cUserID> [, <cPassword>]][, <lShared]]) |
+ | |||
SQLCONNECT([<cServerDataSource>]) | SQLCONNECT([<cServerDataSource>]) | ||
Line 74: | Line 75: | ||
!Return Value||Description | !Return Value||Description | ||
|- | |- | ||
− | |> 0||Statement handle to connection | + | |>0||Statement handle to connection |
|- | |- | ||
|–2||Connection creation error | |–2||Connection creation error |
Revision as of 17:16, 13 March 2009
Contents
SQLCONNECT()
Class
SQL Applications
Purpose
Connect to a data source
Syntax
SQLCONNECT([<nStatementHandle>])
SQLCONNECT([<cConnectionName> | <cDataSourceName> [, <cUserID> [, <cPassword>]][, <lShared]])
SQLCONNECT([<cServerDataSource>])
See Also
CREATE CONNECTION, SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLDISCONNECT(), SQLEXEC(), SQLGETPROP(), SQLMORERESULTS(), SQLPREPARE(), SQLROLLBACK(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES()
Description
The SQLCONNECT() function is used to connect to a data source and return a statement handle for use by other SQL functions.
If SQLCONNECT() is called without specifying any data source information, the Select a Gateway dialog is displayed allowing an existing gateway definition file (.gtw) to be selected. Gateway files can be created in Recital Terminal Developer using the CREATE GATEWAY | MODIFY GATEWAY tool.
Keywords | Description |
---|---|
nStatementHandle | The workarea in which a gateway data source is open and to which a new connection should be made. |
Or
Keywords | Description |
---|---|
cConnectionName | Existing gateway (.gtw) file |
cDataSourceName | ODBC data source name (ODBC supported platforms only) |
cUserID | Data source login user id |
cPassword | Data source login password |
lShared | False (.F.) Connection created is not shared (default)
True (.T.) Connection created is shared |
Or
Keywords | Description |
---|---|
cServerDataSource | ODBC, OLEDB or JDBC server side data source in the format:
odbc:odbc_data_source_name_on_server oledb:oledb_connection_string_on_server jdbc:dbc_driver_path_on_server;jdbc:Recital:args |
Return values:
Return Value | Description |
---|---|
>0 | Statement handle to connection |
–2 | Connection creation error |
Example
// SQLCONNECT() using the 'Select a Gateway' dialog nStatHand=SQLCONNECT() // SQLCONNECT(<nStatementHandle>) to an active gateway opened with SQLSTRINGCONNECT() nStatHand=SQLSTRINGCONNECT("mysql@linux1:user1/pass1-database1.tcpip",.T.) if nStatHand < 1 messagebox([Could not connect]) else messagebox([Connected in workarea ]+str(nStatHand,3)) nStatHand2=SQLCONNECT(nStatHand) if nStatHand2 < 1 messagebox([Could not connect]) else messagebox([Connected in workarea ]+str(nStatHand2,3)) endif endif // SQLCONNECT() to an existing Gateway definition file nStatHand = SQLCONNECT("gateway1.gtw",.T.) // SQLCONNECT() to an ODBC data source nStatHand = SQLCONNECT("SouthWind", "recital", "recital", .T.) //SQLCONNECT() alternative syntax to an ODBC data source nStatHand = SQLCONNECT("odbc:southwind") //SQLCONNECT() to an OLEDB data source nStatHand = SQLCONNECT ("oledb:Provider=vfpoledb.1;" + ; "Data Source=C:Data;Collating Sequence=general")
Products
Recital Database Server, Recital Mirage Server, Recital Terminal Developer