Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
SQLOpen Function
This custom VB function establishes a connection to an ODBC data source.
NOTE: Siebel VB SQLxxxx functions are supported for non-Unicode databases only.
Syntax
SQLOpen(connectString, [outputString][, prompt])
The following table lists the values for prompt. When prompt is omitted, 2 is assumed.
Returns
A long integer representing a unique connection ID, which can be used with other ODBC functions. The completed connection string is returned in outputString if this argument is used. If the connection cannot be established, then an ODBC error with a negative numeric value is returned. Test this value using the instructions in SQLError Function.
Usage
The connectString variable generally takes the following form; however, it must follow the format dictated by the ODBC driver you are using.
"DSN=dataSourceName;UID=loginID;PWD=password"
As the example that follows shows, some parts of this string may not be required; you must supply whatever information is required by the ODBC driver to make the connection. For details on the connect string used to access a Siebel application, read Siebel Technical Note #206.
CAUTION: This function, as well as the other SQL functions available in Siebel VB, should not be used to query the underlying database. Use the Siebel Object Interfaces to query Siebel data. Use the SQL functions only to query non-Siebel data.
Example
This example opens the data source named SblTest, gets the names in the ODBC data sources, and closes the connection.
Sub Button_Click
Dim outputStr As String
Dim connection As Long
Dim prompt As Integer
Dim action As Integer
Dim qualifier As String
Dim datasources(1 To 50) As Variant
Dim retcode As Variant
prompt = 4
Set ret = TheApplication.NewPropertySet()
' Open the datasource "SblTest" with a user name of sa, _
password of sa
connection = _
SQLOpen("DSN=SblTest;UID=sa;PWD=sa",outputStr,prompt:=4)
action = 1 ' Get the names of the ODBC data sources
retcode = SQLGetSchema(connection:=connection, _
action:=1, _
qualifier:=qualifier, _
ref:=datasources())
' Close the data source connection
retcode = SQLClose(connection)
End SubSee Also
SQLClose Function
SQLError Function
SQLExecQuery Function
SQLGetSchema Function
SQLRequest Function
SQLRetrieve Function
SQLRetrieveToFile Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |