Siebel VB Language Reference > Methods Reference for Siebel VB > ODBC Methods >

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:

  • Data source name
  • User ID
  • Password
  • Any other information that the driver requires to make a connection with the data source

The connectString argument typically uses the following format:

"DSN=dataSourceName;UID=loginID;PWD=password"

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:

  • 1. Always display the driver dialog box.
  • 2. Display the driver dialog box only when the specification is not sufficient to make the connection.
  • 3 . Display the driver dialog box only when the specification is not sufficient to make the connection. Dialog boxes that are not required are not available and cannot be modified.
  • 4 . Do not display the driver dialog box. If the connection is not successful, then return an error.

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

Siebel VB Language Reference Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.