Difference between revisions of "SQLCONNECT()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(One intermediate revision by one user not shown)
Line 26: Line 26:
 
|-
 
|-
 
|}
 
|}
 
  
 
Or
 
Or
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 46: Line 44:
 
|-
 
|-
 
|}
 
|}
 
  
 
Or
 
Or
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 
!Keywords||Description
 
!Keywords||Description
 
|-
 
|-
|cServerDataSource||ODBC, OLEDB or JDBC server side data source in the format:
+
|cServerDataSource||ODBC, OLEDB or JDBC server side data source in the format:<br>
odbc:odbc_data_source_name_on_server
+
odbc:odbc_data_source_name_on_server<br>
oledb:oledb_connection_string_on_server
+
oledb:oledb_connection_string_on_server<br>
 
jdbc:dbc_driver_path_on_server;jdbc:Recital:args
 
jdbc:dbc_driver_path_on_server;jdbc:Recital:args
 
|-
 
|-
 
|}
 
|}
 
  
 
====Return values:====
 
====Return values:====
 
  
 
{| class="wikitable"
 
{| class="wikitable"

Latest revision as of 13:33, 13 January 2017

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, Recital Server