Difference between revisions of "SQLSTRINGCONNECT()"

From Lianjapedia
Jump to: navigation, search
m (1 revision: SQL)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
Connect to a data source using a gateway connection string
+
Connect to a data source
 
+
  
 
==Syntax==
 
==Syntax==
SQLSTRINGCONNECT([<lShared>,] [<cConnectString> [, <lShared>]])
+
SQLSTRINGCONNECT(<cConnectString>)
 
+
  
 
==See Also==
 
==See Also==
[[CREATE CONNECTION]], [[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLERROR()]], [[SQLEXEC()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLPREPARE()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLTABLES()]]
+
[[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLERROR()]], [[SQLEXEC()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLPREPARE()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLTABLES()]], [[SQLTRANSACTION()]]
  
 
==Description==
 
==Description==
The SQLSTRINGCONNECT() function is used to connect to a data source using a gateway connection string and return a statement handle for use by other SQL functions.
+
The SQLSTRINGCONNECT() function is used to connect to a data source and return a statement handle for use by other SQL functions.
  
 
+
{| class="wikitable" width="100%"
{| class="wikitable"
+
!width="30%"|Keywords||width="70%"|Description
!Keywords||Description
+
|-
+
|lShared||False (.F.) Connection created is not shared (default)
+
True (.T.) Connection created is shared
+
 
|-
 
|-
|cConnectString||The data source gateway connection string.  The cConnectString gateway connection string format is: server@machinename:username/password-database.protocol.  The shortened driver:datasource format can also be used for ODBC, OLEDB or JDBC data sources on the server.
+
|cConnectString||The ODBC data source connection string or ODBC DSN.
If cConnectString is not specified, 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 or via the CREATE CONNECTION command.
+
|-
+
|}
+
 
+
 
+
====cConnectString:====
+
 
+
 
+
{| class="wikitable"
+
!Parameter||Description
+
|-
+
|Server||Database server name or abbreviation, e.g. mys or mysql.
+
|-
+
|Nodename||IP Address or hostname of the machine on which the database resides.
+
|-
+
|Username||Username to log in to the external database.
+
|-
+
|Password||Password for username above.
+
|-
+
|Database||Database to connect to.
+
|-
+
|Protocol||The network protocol. TCP/IP is assumed.
+
|-
+
|Driver:DataSource ||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
+
 
|-
 
|-
 
|}
 
|}
Line 55: Line 20:
 
====Return values:====
 
====Return values:====
  
 
+
{| class="wikitable" width="100%"
{| class="wikitable"
+
!width="30%"|Return Value||width="70%"|Description
!Return Value||Description
+
 
|-
 
|-
|> 0||The workarea in which the gateway data source has been opened
+
|> 0||Statement handle to the connection
 
|-
 
|-
 
|&ndash;1||Connection creation error
 
|&ndash;1||Connection creation error
 
|-
 
|-
 
|}
 
|}
 
  
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
// When cConnectString is omitted, ’Select a Gateway’ dialog is displayed
 
// Specify connection should be shared
 
nStatHand = SQLSTRINGCONNECT(.T.)
 
 
// Including cConnectString makes the connection
 
 
// Store the return value to use as the nStatementHandle for subsequent function calls
 
// Store the return value to use as the nStatementHandle for subsequent function calls
// Specify connection should be shared
+
// Specify an ODBC DSN
nStatHand = SQLSTRINGCONNECT("mysql@linux1:user1/pass1-database1.tcpip",.T.)
+
nStatHand = sqlstringconnect("awhr")
 
+
// or an ODBC connection string
// OLEDB DataSource
+
nStatHand = sqlstringconnect("Driver={SQL Server};Server=MYPC-PC\INST1;Trusted_Connection=yes;Database=AdventureWorks;")
nStatHand = SQLSTRINGCONNECT ("oledb:Provider=vfpoledb.1;" +;
+
"Data Source=C:Data;Collating Sequence=general",.T.)
+
 
</code>
 
</code>
  
 
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:SQL]]
 
[[Category:SQL]]
[[Category:Remote Data Connectivity Functions]]
+
[[Category:ODBC Functions]]
 +
[[Category:SQL Functions]]

Latest revision as of 10:02, 4 February 2013

Purpose

Connect to a data source

Syntax

SQLSTRINGCONNECT(<cConnectString>)

See Also

SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLERROR(), SQLEXEC(), SQLGETPROP(), SQLMORERESULTS(), SQLPREPARE(), SQLROLLBACK(), SQLSETPROP(), SQLTABLES(), SQLTRANSACTION()

Description

The SQLSTRINGCONNECT() function is used to connect to a data source and return a statement handle for use by other SQL functions.

Keywords Description
cConnectString The ODBC data source connection string or ODBC DSN.

Return values:

Return Value Description
> 0 Statement handle to the connection
–1 Connection creation error

Example

// Store the return value to use as the nStatementHandle for subsequent function calls
// Specify an ODBC DSN
nStatHand = sqlstringconnect("awhr")
// or an ODBC connection string
nStatHand = sqlstringconnect("Driver={SQL Server};Server=MYPC-PC\INST1;Trusted_Connection=yes;Database=AdventureWorks;")