ODBC Open Connection Method
The ODBC Open Connection method is a Siebel VB method that establishes a connection to an ODBC data source. It returns a long integer that identifies a unique connection ID that you can use with other ODBC methods. If you include the outputString argument, then it returns the completed connection string in the outputString argument.
If it cannot establish a connection, then it returns an ODBC error with a negative numeric value. You can test for this value. For more information, see ODBC Get Errors Method.
Format
SQLOpen(connectString, [outputString][, prompt])
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
connectString |
A string or string variable that includes the following information:
The connectString argument typically uses the following format:
However, it must use the format that the ODBC driver requires. Some parts of this string might not be required. For more information on the string you use to access a Siebel application, see Siebel Technical Note #206 on My Oracle Support. |
outputString |
A string variable that holds the completed connection string. |
prompt |
One of the following integers that specifies when to display the driver dialog box:
If you do not include the prompt argument, then Siebel VB uses value 2. |
Example
The following example opens the data source named SblTest, gets the names in the ODBC data sources, and then 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