Click or drag to resize

SQLSetConnection Function

X#
Return and optionally change the default SQL connection.

Namespace:  XSharp_VOSQLClasses
Assembly:  XSharp.VOSQLClasses (in XSharp.VOSQLClasses.dll) Version: 2.19
Syntax
 FUNCTION SQLSetConnection(
	oSQLConnection
) AS SQLConnection CLIPPER
Request Example View Source

Parameters

oSQLConnection (Optional)
Type: Usual
The default SQL connection that will be used by any function or class that requires a connection.

Return Value

Type: SQLConnection
If oSQLConnection is not specified, SQLSetConnection() returns the current setting. If oSQLConnection is specified, the new setting is returned.
Remarks
If oSQLConnection is not specified and there is no previous or default connection, SQLSetConnection() calls SQLOpenConnection(), sets that connection as the default, and returns it.
Examples
The following example tests connection utility functions:
X#
 1FUNCTION TestConnect()
 2LOCAL wCount AS DWORD
 3LOCAL aSources AS ARRAY
 4LOCAL oConn AS SQLConnection
 5// Get an array of sources
 6aSources := SQLGetDataSources()
 7// List them
 8? "ODBC Sources..."
 9for wCount := 1 to ALen(aSources)
10? aSources[wCount]
11next
12// Connect to a list of sources
13oConn := SQLOpenConnection()
14// Make it the default connection
15SQLSetConnection(oConn)
16// Disconnect
17oConn:Disconnect()
See Also