Siebel VB Language Reference > 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])
|
|
connectString |
A string or string variable supplying the information required to connect to a data source, including the data source name, user ID, and password, and any other information required by the driver to make the connection |
outputString |
A string variable to hold the completed connection string if the connection is successful |
prompt |
An integer specifying when the driver dialog box is displayed |
The following table lists the values for prompt. When prompt is omitted, 2 is assumed.
|
|
1 |
Driver dialog box is always displayed |
2 |
Driver dialog box is displayed only when the specification is not sufficient to make the connection |
3 |
The same as 2, except that dialog boxes that are not required are unavailable and cannot be modified |
4 |
Driver dialog box is not displayed; if the connection is not successful, an error is returned |
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 Sub
Related Topics
SQLClose Function SQLError Function SQLExecQuery Function SQLGetSchema Function SQLRequest Function SQLRetrieve Function SQLRetrieveToFile Function
|