OdbcTestX Component

The ODBCTESTX ActiveX component allows you to perform simple ODBC related functions from a program without having to include the Microsoft Data Objects interface (large and full of features you may not need) or having to code direct calls to the ODBC API (complex and error-prone ). The component only runs under 32-bit Windows. The component allows you to:

 However, You should not use the ODBCTESTX component if you plan to:

The ODBCTESTX ActiveX component can be called from any language that supports COM. This includes Visual C++ and Visual Basic, Delphi, HTML script languages, Internet pages, Java and Centura Team Developer, but many others should work as well. Please note that:

Installing the component
Software Version Information
The raison d'être for the component
Version overview
Using the Component in Your Programs
Sample Visual Basic Program
Reference to Attributes and Methods
ODBC Data Types

Installing the component

Move the component ( ODBCTSTX.DLL ) to some directory, possibly the Windows System directory, and register the component from a command prompt with:'

cd your\directory
regsvr32 ODBCTSTX.DLL

See the sample code included with the component for a VB example of how to include the component in your own programs. To use the component you have to add it to the VB tool-box (with the Project->Components... menu selection).

Software Version Information

This document refers to version 2.1 of the OdbctestX program/component dated 2000-08-21.

The raison d'être for the component

Why write an ActiveX component that simply allows you to issue basic SQL commands against ODBC data sources? The world is filled with fancy ODBC enabled components and a part from that most modern programming languages have advanced ODBC interfaces (like the DAO interface in Visual Basic and C++). To add one more component to the pile may seem like inventing the wheel again just for the fun of it, so a few words of explanation from the author may be in order:

To my experience all those fancy components and advanced interfaces have a common failing - They try to do all things to all people. Well, I am a simple guy; I just want to do simple things to my database. I get thoroughly annoyed when I have to use my time figuring out the intricacies of DAO or whatever, when all I want is two or three simple functions to access my ODBC database.

So here is a simple component that does what's needed and not much more. The component is written for the Windows platform as a COM component in C++. It is reasonably small and efficient, and due to the ActiveX interface it can be called from almost any modern programming language.

I hope you will use the component to make some great programs. We have placed the component on the Internet as freeware. The only payment we want for the component is that you mention ISS Data and the author in your application's About Dialog and in your application's documentation .

Good luck,

Jorgen Grosbol,
ISS Data

Version overview

Version 1.0 (and 1.1) (autumn 1997)

This is the original version of the component to be placed on the Internet.

Version 1.2 (January 1998)

This version contains all the functionality of the original component with the following additions:

Version 2.0 (July 2000)

This version is a complete rewrite of the original component (with new GUID). It is mostly functionally identical to the 1.2 version, but is much smaller and require fewer standard DLL files to run. The one change in version 2.0 is that the SelectTableNames() method no longer requires a Types argument.

Version 2.1 (August 2000)

Just minor fixes:

Using the Component in Your Programs

To use the component you have to register it in the Windows registry and you have to place some DLL and OCX files in the Windows System directory . The install program does this for you , but if you include the component in your own applications you have to install it on the target systems where your program will be executed. You can do this by simply including the INSTALL.EXE file with your installation and have your users execute it before using your own application, or you can have your own installation program place the correct files in the users system. If you choose the latter option you need the information below:

  1. To use the component, you need the following standard DLL files:

    ODBC32.DLL
    KERNEL32.DLL
    USER32.DLL
    GDI32.DLL
    ADVAPI32.DLL
    COMCTL32.DLL
    OLE32.DLL
    OLEPRO32.DLL
    OLEAUT32.DLL
  2. You must register the component with the system. The component is self-registering, so most installation programs will do this for you. You may want to use the Type Library supplied in the installation directory ( OdbcTestX.tlb ), or you can use the Microsoft program RegSvr32.exe to register the component.

Sample Visual Basic Program

If you have Visual Basic installed on your system you may want to look at the sample program supplied in the installation directory. The program consists of a single form that allows you to activate different OdbcTestX functions. Below is a short description of how you would use the component to perform some simple tasks from Visual Basic. While syntactically different most other languages will conform to the same general logic as shown in the examples, so you should be able to use the guide even if your language of choice is not Visual Basic.

Accessing the component from Visual Basic
Listing all available ODBC data sources
Controlling Commit and Rollback
Connecting to an ODBC Data Source
Issuing an SQL command
Getting the names of the fetched columns
Reading the fetched data rows
Translating text columns
Finding all tables in a data source
Finding all columns in a table

Accessing the component from Visual Basic

To use the component in a Visual Basic program you have to do the following:

  1. Check the component in the list of available components in the component list in the Project menu . This will place a small icon representing the component in the toolbox.
  2. Place at least one copy of the component in some form in your project. The component is invisible at runtime, so you can place it anywhere you want. Give it a name of your choosing. In the sample program the default name ( OdbcTestX1 ) has been used.

Listing all available ODBC data sources

Use the GetSourceNames method to get a list of all available ODBC data sources in the system. The argument defines a string that is placed between each information in the returned list. You can then use program statements to break the list into its parts. The example below demonstrates how you can put the name and description of each data source in a list box:


  Dim names As String, delim As String
  Dim i As Integer, descr As String, source As String
  delim = "++"
  List1.Clear
  names = OdbcTestX1.GetSourceNames(delim)
  i = InStr(names, delim)
  While i > 0
    source = Mid(names, 1, i - 1)
    names = Mid(names, i + 2)
    i = InStr(names, delim)
    descr = Mid(names, 1, i - 1)
    names = Mid(names, i + 2)
    List1.AddItem source & " - " & descr
    i = InStr(names, delim)
  Wend

Controlling Commit and Rollback

Before you open the ODBC data source you should decide whether you want to use auto-commit or not. The default is that the AutoCommit attribute is turned off ( false ). Please consider that

  1. If AutoCommit is set to true then all successful SQL statements will be immediately committed to the database system. This effectively prevents you from issuing RollBack commands later to undo your changes.
  2. If AutoCommit is set to false you have to issue Commit and RollBack commands yourself to commit changes to the database system. If you do not yourself issue these commands a single commit will be issued when you disconnect from the ODBC data source.

Please note that some ODBC drivers may have external parameters that determine their mode of operation.

Connecting to an ODBC Data Source

 You connect to an ODBC data source by specifying the source name , user id and password to the component and then issuing the Connect method:


OdbcTestX1.source = "SourceName"
OdbcTestX1.Userid = "Userid"
OdbcTestX1.Password = "Password"
OdbcTestX1.AutoCommit = True
emsg = OdbcTestX1.Connect
If emsg = "OK" Then
 MsgBox "Connected"
Else
 MsgBox "Error: " & emsg
End If

You can only open one data source at a given time in each component, but you can add as many OdbcTextX components to your project as you like.

Issuing an SQL command

Once you have connected to a data source you can issue SQL commands to it. Use the ExecuteSql command to perform SQL commands:

Dim emsg As String, command as String
command = "SELECT * FROM CREATOR.MYTABLE"
emsg = OdbcTestX1.ExecuteSql(command)

Afterwards the emsg variable will either contain the text "OK" or an ODBC error message. If you issue an SQL SELECT statement (as in the example above) you can use the Fetch and ColumnValue functions to retrieve the actual data in the fetched table.

Getting the names of the fetched columns

 When you have issued a SELECT command you can query the number of returned columns and their names like this:


Dim colcount as Long, colname as String, colnumber as long
colcount = OdbcTestX1.ColumnCount
If colcount < 1 Then Exit Sub ' no result set found, exit here
For colnumber = 1 To colcount
 colname = OdbcTestX1.ColumnName(colnumber)
 ' use the column name in colname for something ...
Next colnumber

There are also other attributes that allow you to get column information. These include:

OdbcTestX1.ColumnName(colnumber)
OdbcTestX1.ColumnType(colnumber)
OdbcTestX1.ColumnLength(colnumber)
OdbcTestX1.ColumnPrecision(colnumber)
OdbcTestX1.ColumnScale(colnumber)
OdbcTestX1.ColumnIsNullable(colnumber)

Reading the fetched data rows

 You issue SQL SELECT statements to build result sets. These Result sets can be read one row at a time with the Fetch method and the data value in each column in the row can be retrieved with the ColumnValue attribute. It could look something like this:


  Dim colcount as Long, colnumber as Long
  Dim dataline as String, colvalue as String, emsg as String
  colcount = OdbcTestX1.ColumnCount
  While OdbcTestX1.Fetch(emsg)
    dataline = " "
    For colnumber = 1 To colcount
      If OdbcTestX1.IsNull(colnumber) Then
        colvalue = "[NULL]"
      Else
        colvalue = OdbcTestX1.ColumnValue(colnumber)
      End If
      dataline = dataline & colvalue & "; "
    Next colnumber
    List1.AddItem dataline
  Wend
  If emsg <> "OK" Then List1.AddItem "Error: " & 
emsg

Translating text columns

You can have the OdbcTestX component translate the character of text columns being read. This is done by issuing a SetTranslateTable method just before the ColumnValue is referenced. The translate table stays in effect until you define another table by a call to SetTranslateTable. The first argument defines the characters you want OdbcTExtX to translate, the second argument defines what characters you want them translated into. The example below is identical to the previous example except that all character columns have the character '#' translated into the Danish national character 'Æ'. Also '@' in translated into 'Ø' and '$' is translated into 'Å'.



  Dim colcount as Long, colnumber as Long
  Dim dataline as String, colvalue as String, emsg as String
  colcount = OdbcTestX1.ColumnCount
 OdbcTestX1.SetTranslateTable "#@$", 
"ÆØÅ"

   While OdbcTestX1.Fetch(emsg)
    dataline = " "
    For colnumber = 1 To colcount
      If OdbcTestX1.IsNull(colnumber) Then
        colvalue = "[NULL]"
      Else
        colvalue = OdbcTestX1.ColumnValue(colnumber)
      End If
      dataline = dataline & colvalue & "; "
    Next colnumber
    List1.AddItem dataline
  Wend
  If emsg <> "OK" Then List1.AddItem "Error: " & 
emsg

Finding all tables in a data source

The SelectTableNames method creates a result set containing the names of all the tables in the currently connected ODBC data source. The method has some arguments that allow you to limit the number of returned table names (which can be practical when accessing mainframe databases where the number of tables may be quite large). You use the SelectTableNames method like this:


  Dim emsg as String, qualifier_mask as String
  Dim creator_mask as string, table_mask as String
  qualifier_mask = ""
  creator_mask = "DAP%"
  table_mask = "TB%"
  emsg = OdbcTestX1.SelectTableNames(qualifier_mask, _
         creator_mask, table_mask, 0)
  If emsg <> "OK" Then
    MsgBox "Error: " & emsg
    Exit Sub
  End If

You read the actual table names from the result set as you would any other result set , i.e. with Fetch and ColumnValue commands. See the description of the SelectTableNames method for details on the format of the returned table.

Finding all columns in a table

 The SelectColumnNames method creates a result set containing the names of all columns in the tables in the currently connected ODBC data source. The method has some arguments that allow you to limit the number of returned column. You would typically only want to get the column names for one table in each call of the method. You use the SelectColumnNames method like this:


  Dim emsg as String, qualifier_mask as String
  Dim creator_mask as string, table_mask as String
  qualifier_mask = ""
  creator_mask = "DAPZ1"
  table_mask = "TBUSERNAMES"
  emsg = OdbcTestX1.SelectColumnNames(qualifier_mask, _
         creator_mask, table_mask, "")
  If emsg <> "OK" Then
    MsgBox "Error: " & emsg
    Exit Sub
  End If

You read the actual table names from the result set as you would any other result set , i.e. with Fetch and ColumnValue commands. See the description of the SelectColumnNames method for details on the format of the returned table.

Reference to Attributes and Methods

Below is a list of all attributes and methods available in the ODBCTESTX component. Some entry points exist in two versions. The version suffixed with 'S' is internally simpler and may work in certain 3rd party software packages that do not support the dual-interface mechanism used in the non-S version.

String Author
String Copyright
String Version
String Compiled
String Email
String UserParm
String Source
String UserId
String Password
String GetSourceNames(String Delimiter)
Boolean AutoCommit
Commit
RollBack
Long MaxVarcharSize
String Connect
Boolean Disconnect
String ExecuteSql(String SqlCommand)
Boolean Fetch(String ErrorMessage) or String FetchS()
Long ColumnCount
Long RowCount
String ColumnName (Long ColumnNumber )
Long ColumnType(Long ColumnNumber )
Long ColumnLength(Long ColumnNumber )
Long ColumnPrecision(Long ColumnNumber )
Long ColumnScale(Long ColumnNumber )
Boolean ColumnIsNullable(Long ColumnNumber )
String ColumnValue (Long ColumnNumber)
Boolean IsNull(Long ColumnNumber )
String SelectTableNames(String QualifierMask, String CreatorMask, String TableMask)
SetTranslateTable (String FromLetters,String ToLetters)
String SelectColumnNames(String QualifierMask, String CreatorMask, String TableMask, String ColumnMask)

String Author

String attribute. Returns a string variable containing the name of the author of the component. This attribute cannot be set.

String Copyright

String attribute. Returns a string variable containing a copyright message for the component. This attribute cannot be set.

String Version

String attribute. Returns a string variable containing the current version number of the component. This attribute cannot be set.

String Compiled

String attribute. Returns a string variable containing the date when the component was last compiled. This attribute cannot be set.

String Email

String attribute. Returns a string variable containing the e-mail address of the author of the component. This attribute cannot be set.

String UserParm

String attribute. This text value is not used by the component. You can use it to store and retrieve any relevant text information. One typical use could be to place a user-friendly name for the data source here.

String Source

String attribute. Contains the ODBC Data source name used when connecting to ODBC. You must set this attribute before connection or issuing other database access commands.

String UserId

String attribute. Contains the user id used when connecting to the ODBC data source. You should set this attribute before connection or issuing other database access commands to avoid having the user prompted for passwords by the ODBC driver.

String Password

String attribute. Contains the password used when connecting to the ODBC data source. You should set this attribute before connection or issuing other database access commands to avoid having the user prompted for passwords by the ODBC driver. Be aware that if you save this property in your project the password will be saved in un-coded form. For this reason you may want to supply the password yourself during runtime.

String GetSourceNames(String Delimiter)

String Method. Returns a string containing all available ODBC data source names and descriptions in the system. Each data source results in the following being added to the result string:

SourceName XXX SourceDescription XXX

where XXX is the string specified in the Delimiter parameter. See the coding example in the sample program.

Boolean AutoCommit

Boolean attribute. Set this attribute before opening a connection. If set to true all SQL commands are automatically committed to the database system. If set to false you have to issue the Commit or RollBack commands yourself.

Commit

Method. Performs a commit against the database system currently connected to. Alternatively you may want to use the AutoCommit option to automatically commit each SQL statement to the database system.

RollBack

Method. Performs a rollback against the database system currently connected to. If you want to perform RollBack commands you should ensure that the AutoCommit option is set to false.

Long MaxVarcharSize

Long integer attribute. Defines the maximum size of long varying fields processed by the component. Longer fields will be truncated. The default value is 32000 bytes.

String Connect

Method returning a string. Performs a connect to the ODBC data source specified in the Source option using the user id and password set in the UserID and Password options. The method returns a string that is either "OK" (if the connection was achieved) or an ODBC error message (if an error occurred).

Boolean Disconnect

Method returning a Boolean value. Disconnects from the currently connected to ODBC data source. The return value is true if a disconnection was performed and false if no connection existed to disconnect.

String ExecuteSql(String SqlCommand)

Method returning a string. Executes the SQL statement specified in the SqlCommand argument. You must have successfully connected to a data source before you can execute SQL statements. The return value is either "OK" (if everything went well) or an ODBC error message (in case of failure).

Boolean Fetch(String ErrorMessage) or String FetchS()

These methods fetch the next row from the current result set. The first method returns true if more rows remained and false if end-of-file were encountered. The ErrorMessage string is an output parameter. It is set to "OK" if no ODBC errors occurred and to an ODBC error message or "EOT" (end of table) otherwise. The second method (FetchS) simply returns the error message - You can compare the message to "OK" to see if a row was fetched.

Long ColumnCount

Long integer attribute. Contains the number of columns in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command. This attribute cannot be set.

Long RowCount

Long integer attribute. Contains the current number of rows in the result set resulting from the last executed SQL command or SelectTableNames or SelectColumnNames command. If the driver does not support this function a value of -1 is returned. This attribute cannot be set.

Note - not all database systems support this attribute for all functions. While most systems return the number of deleted rows here after an SQL DELETE request, only a few will return the number of rows in the result set from a SELECT command. You will have to try out each command to find out whether your database system supports this attribute or not.

String ColumnName (Long ColumnNumber )

String attribute. Contains the name of the column having the given number in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command. This attribute cannot be set. Columns are numbered starting with one (1).

Long ColumnType(Long ColumnNumber )

Long integer attribute. Contains the type of the column having the given number in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command. This attribute cannot be set. Columns are numbered starting with one (1).

See below for a list of ODBC data types .

Long ColumnLength(Long ColumnNumber )

Long integer attribute. Contains the length of the column having the given number in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command. This attribute cannot be set. Columns are numbered starting with one (1).

Long ColumnPrecision(Long ColumnNumber )

Long integer attribute. Contains the precision of the column having the given number in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command. This attribute cannot be set. Columns are numbered starting with one (1).

Long ColumnScale(Long ColumnNumber )

Long integer attribute. Contains the scale value of the column having the given number in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command. This attribute cannot be set. Columns are numbered starting with one (1).

Boolean ColumnIsNullable(Long ColumnNumber )

Boolean value attribute. Contains True if the column having the given number in the current result set from the last executed SQL command or SelectTableNames or SelectColumnNames command can contain NULL values and False otherwise. This attribute cannot be set. Columns are numbered starting with one (1).

String ColumnValue (Long ColumnNumber)

String attribute. Contains the value of the specified column in the current row in the current result set. Non-character columns are converted to character format if possible. This attribute cannot be set. Columns are numbered starting with one (1).

Boolean IsNull(Long ColumnNumber )

Boolean attribute. Contains true if the value of the specified column in the current row in the current result set has a NULL value and false otherwise. This attribute cannot be set. Columns are numbered starting with one (1).

String SelectTableNames(String QualifierMask, String CreatorMask, String TableMask)

Method returning a string. Places a table containing the list of all objects (views, tables, synonyms...) in the ODBC data source fitting the specified masks. The masks variables can be empty (includes all objects), or can hold SQL mask characters like '%' (percent sign). Note that not all ODBC drivers support mask characters. Also note that some systems compare names in a case-dependent way.

You have to connect to the data source before the SelectTableNames method can be executed. You can read the result set row by row using the Fetch method and you can get the actual information using the ColumnValue () property. The table returned contains the following columns:


1: TABLE_QUALIFIER
2: TABLE_OWNER
3: TABLE_NAME
4: TABLE_TYPE
5: REMARKS

The returned string is either "OK" (if everything worked out) or an ODBC error message (in case of failure).

SetTranslateTable (String FromLetters,String ToLetters)

This method defines the translation that will take place each time you use the ColumnValue method to get the value of a string column. Each letter in the first argument string is translated into the corresponding letter in the second argument string. The translation takes place when you call ColumnValue , so you can dynamically change the translate-table even after you have retrieved some of the columns of a row. Each call to SetTranslateTable completely removes the previous translate-table, so you have to specify all letters to be translated in the same function call.

Note: Characters are not translated when storing data in the database using INSERT or UPDATE SQL statements. Also note that only columns of type 1 (CHAR) and 12 (VARCHAR) are translated when ColumnValue is called.

String SelectColumnNames(String QualifierMask, String CreatorMask, String TableMask, String ColumnMask)

Method returning a string. Places a table containing the list of columns in all objects (views and tables) in the ODBC data source fitting the specified masks. The masks variables can be empty (includes all objects), or can hold SQL mask characters like '%' (percent sign). Note that not all ODBC drivers support mask characters. Also note that some systems compare names in a case-dependent way. You have to connect to the data source before the SelectColumnNames method can be executed. You can read the result set row by row using the Fetch method and you can get the actual information using the ColumnValue () property. The table returned contains the following columns:


1: TABLE_QUALIFIER
2: TABLE_OWNER
3: TABLE_NAME
4: COLUMN_NAME
5: DATA_TYPE
6: TYPE_NAME
7: PRECISION
8: LENGTH
9: SCALE
10: RADIX
11: NULLABLE
12: REMARKS

See the paragraph on ODBC Data Types for how to interpret the DATA_TYPE column.

ODBC Data Types

Internally ODBC uses an integer value to define the data format of a column in a table. These numbers can be found in the ODBC systems documentation, but for your convenience the list below gives the more common data type numbers:


UNKNOWN_TYPE   0
CHAR           1
NUMERIC        2
DECIMAL        3
INTEGER        4
SMALLINT       5
FLOAT          6
REAL           7
DOUBLE         8
DATETIME       9
TIME          10
TIMESTAMP     11
VARCHAR       12
LONGVARCHAR   -1
BINARY        -2
VARBINARY     -3
LONGVARBINARY -4
BIGINT        -5
TINYINT       -6

The formats above are used by ODBCTESTX internally, but generally you do not have to know the data type of your to retrieve them as the component converts data to character format where possible.

Beware that the actual data format used in the database system can vary from the format used by ODBC, so you will not always be able to guess the data type even if you know the format of the original column in the table.

VB Sample Program code


VERSION 5.00
Object = "{45EA6FED-517B-11D4-9B0A-0000834A2B6A}#1.0#0"; 
"OdbctstX.dll"
Begin VB.Form Form1
  Caption         =   "Form1"
  ClientHeight    =   7788
  ClientLeft      =   48
  ClientTop       =   276
  ClientWidth     =   7848
  LinkTopic       =   "Form1"
  ScaleHeight     =   7788
  ScaleWidth      =   7848
  StartUpPosition =   3  'Windows Default
  Begin VB.TextBox Text10
     Height          =   288
     Left            =   4080
     TabIndex        =   31
     Text            =   "Text10"
     Top             =   2640
     Width           =   2292
  End
  Begin VB.TextBox Text9
     Height          =   288
     Left            =   1320
     TabIndex        =   29
     Text            =   "Text9"
     Top             =   2640
     Width           =   2172
  End
  Begin VB.TextBox Text8
     Height          =   372
     Left            =   6480
     TabIndex        =   27
     Text            =   "Text8"
     Top             =   2160
     Width           =   1212
  End
  Begin VB.TextBox Text7
     Height          =   372
     Left            =   5040
     TabIndex        =   26
     Text            =   "Text7"
     Top             =   2160
     Width           =   1332
  End
  Begin VB.TextBox Text6
     Height          =   372
     Left            =   3600
     TabIndex        =   25
     Text            =   "Text6"
     Top             =   2160
     Width           =   1332
  End
  Begin VB.TextBox Text5
     Height          =   372
     Left            =   2160
     TabIndex        =   24
     Text            =   "Text5"
     Top             =   2160
     Width           =   1332
  End
  Begin VB.CommandButton Command6
     Caption         =   "Columns"
     Height          =   372
     Left            =   1080
     TabIndex        =   23
     Top             =   2160
     Width           =   852
  End
  Begin VB.CommandButton Command5
     Caption         =   "Tables"
     Height          =   372
     Left            =   120
     TabIndex        =   22
     Top             =   2160
     Width           =   852
  End
  Begin VB.CommandButton Command4
     Caption         =   "Fetch"
     Height          =   372
     Left            =   3000
     TabIndex        =   21
     Top             =   1680
     Width           =   1212
  End
  Begin VB.CommandButton Command3
     Caption         =   "Execute SQL"
     Height          =   372
     Left            =   1560
     TabIndex        =   20
     Top             =   1680
     Width           =   1332
  End
  Begin VB.TextBox Text4
     Height          =   1572
     Left            =   120
     TabIndex        =   18
     Text            =   "Text4"
     Top             =   6120
     Width           =   7572
  End
  Begin VB.CommandButton Command2
     Caption         =   "Disconnect"
     Height          =   372
     Left            =   4320
     TabIndex        =   17
     Top             =   1680
     Width           =   1212
  End
  Begin VB.CommandButton Command1
     Caption         =   "Connect"
     Height          =   372
     Left            =   120
     TabIndex        =   16
     Top             =   1680
     Width           =   1332
  End
  Begin VB.TextBox Text3
     Height          =   288
     Left            =   5040
     TabIndex        =   14
     Text            =   "Text3"
     Top             =   1200
     Width           =   2652
  End
  Begin VB.CheckBox Check1
     Caption         =   "AutoCommit"
     Height          =   252
     Left            =   6120
     TabIndex        =   12
     Top             =   1560
     Width           =   1572
  End
  Begin VB.TextBox Text2
     Height          =   288
     IMEMode         =   3  'DISABLE
     Left            =   5040
     PasswordChar    =   "*"
     TabIndex        =   8
     Text            =   "Text2"
     Top             =   840
     Width           =   2652
  End
  Begin VB.TextBox Text1
     Height          =   288
     Left            =   5040
     TabIndex        =   7
     Text            =   "Text1"
     Top             =   480
     Width           =   2652
  End
  Begin VB.ComboBox Combo1
     Height          =   288
     Left            =   5040
     Sorted          =   -1  'True
     TabIndex        =   6
     Text            =   "Combo1"
     Top             =   120
     Width           =   2652
  End
  Begin VB.Frame Frame1
     Caption         =   "Component Info"
     Height          =   1572
     Left            =   120
     TabIndex        =   0
     Top             =   0
     Width           =   3492
     Begin VB.Label Label0
        Caption         =   "Label5"
        Height          =   252
        Left            =   240
        TabIndex        =   5
        Top             =   240
        Width           =   3132
     End
     Begin VB.Label Label4
        Caption         =   "Label4"
        Height          =   252
        Left            =   240
        TabIndex        =   4
        Top             =   1200
        Width           =   3132
     End
     Begin VB.Label Label3
        Caption         =   "Label3"
        Height          =   252
        Left            =   240
        TabIndex        =   3
        Top             =   960
        Width           =   3132
     End
     Begin VB.Label Label2
        Caption         =   "Label2"
        Height          =   252
        Left            =   240
        TabIndex        =   2
        Top             =   720
        Width           =   3132
     End
     Begin VB.Label Label1
        Caption         =   "Label1"
        Height          =   252
        Left            =   240
        TabIndex        =   1
        Top             =   480
        Width           =   3132
     End
  End
  Begin VB.Label Label12
     Caption         =   "To:"
     Height          =   252
     Left            =   3720
     TabIndex        =   30
     Top             =   2640
     Width           =   372
  End
  Begin VB.Label Label11
     Caption         =   "Translate from:"
     Height          =   252
     Left            =   120
     TabIndex        =   28
     Top             =   2640
     Width           =   1212
  End
  Begin ODBCTESTXLibCtl.OdbcTestX OdbcTestX1
     Left            =   6480
     OleObjectBlob   =   "Form1.frx":0000
     Top             =   2760
  End
  Begin VB.Label Label10
     Caption         =   "SQL statement:"
     Height          =   252
     Left            =   120
     TabIndex        =   19
     Top             =   5760
     Width           =   2412
  End
  Begin VB.Label Label9
     BackColor       =   &H80000018&
     BorderStyle     =   1  'Fixed Single
     Caption         =   "Label9"
     BeginProperty Font
        Name            =   "MS Sans Serif"
        Size            =   9.6
        Charset         =   0
        Weight          =   400
        Underline       =   0   'False
        Italic          =   0   'False
        Strikethrough   =   0   'False
     EndProperty
     Height          =   2772
     Left            =   120
     TabIndex        =   15
     Top             =   3000
     Width           =   7572
     WordWrap        =   -1  'True
  End
  Begin VB.Label Label8
     Caption         =   "MaxVarChar"
     Height          =   252
     Left            =   3840
     TabIndex        =   13
     Top             =   1200
     Width           =   1092
  End
  Begin VB.Label Label7
     Caption         =   "Password"
     Height          =   252
     Left            =   3840
     TabIndex        =   11
     Top             =   840
     Width           =   1092
  End
  Begin VB.Label Label6
     Caption         =   "Userid:"
     Height          =   372
     Left            =   3840
     TabIndex        =   10
     Top             =   480
     Width           =   1092
  End
  Begin VB.Label Label5
     Caption         =   "Source:"
     Height          =   252
     Left            =   3840
     TabIndex        =   9
     Top             =   120
     Width           =   1092
  End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()

OdbcTestX1.AutoCommit = Check1
OdbcTestX1.Source = Combo1
OdbcTestX1.UserId = Text1
OdbcTestX1.Password = Text2
OdbcTestX1.MaxVarcharSize = Text13

Label9 = OdbcTestX1.Connect

End Sub

Private Sub Command2_Click()

 If OdbcTestX1.Disconnect Then
   Label9 = "Disconnected"
 Else
   Label9 = "Not Conencted"
 End If

End Sub

Private Sub Command3_Click()

 Dim msg As String
 Dim n As Long

 msg = OdbcTestX1.ExecuteSql(Text4)
 If msg = "OK" Then
   msg = "ROWS: " & OdbcTestX1.RowCount & ", COLUMNS: 
" & OdbcTestX1.ColumnCount &
Chr(10)
   For n = 1 To OdbcTestX1.ColumnCount
     msg = msg & OdbcTestX1.ColumnName(n)
     msg = msg & ", Type: " & OdbcTestX1.ColumnType(n)
     msg = msg & ", Length: " & OdbcTestX1.ColumnLength(n)
     msg = msg & ", Scale: " & OdbcTestX1.ColumnScale(n)
     msg = msg & ", Precision: " & 
OdbcTestX1.ColumnPrecision(n)
     msg = msg & ", Nullable: " & 
OdbcTestX1.ColumnIsNullable(n)
     msg = msg & Chr(10)
   Next

 End If

 Label9 = msg

End Sub

Private Sub Command4_Click()
 Dim ok As Boolean, msg As String, status As String, maxcnt As Long
 If OdbcTestX1.Fetch(status) Then
   For n = 1 To OdbcTestX1.ColumnCount
     msg = msg & OdbcTestX1.ColumnName(n)
     msg = msg & "=" & OdbcTestX1.ColumnValue(n)
     msg = msg & " (NULL=" & OdbcTestX1.IsNull(n)
     msg = msg & ")"
     msg = msg & Chr(10)
   Next
   msg = msg & "------------------" & Chr(10)
   maxcnt = maxcnt - 1
 End If
 Label9 = status & Chr(10) & "-------------------" & 
Chr(10) & msg

End Sub

Private Sub Command5_Click()

 Label9 = OdbcTestX1.SelectTableNames(Text5, Text6, Text7)

End Sub

Private Sub Command6_Click()

 Label9 = OdbcTestX1.SelectColumnNames(Text5, Text6, Text7, Text8)

End Sub

Private Sub Form_Load()

 Dim sources() As String, n As Long

 OdbcTestX1.UserParm = "ODBCTESTX component"
 Label0 = OdbcTestX1.UserParm
 Label1 = OdbcTestX1.Author
 Label2 = OdbcTestX1.Copyright
 Label3 = OdbcTestX1.Version
 Label4 = OdbcTestX1.Email

 Label9 = ""

 sources = Split(";" & OdbcTestX1.GetSourceNames(";"), 
";")
 For n = 1 To UBound(sources)
   Combo1.AddItem sources(n)
 Next
 Combo1.ListIndex = 4 ' Default data source index number

 Text1 = OdbcTestX1.UserId
 Text2 = OdbcTestX1.Password
 Text3 = OdbcTestX1.MaxVarcharSize
 Check1 = OdbcTestX1.AutoCommit

 Text4 = "SELECT * From DEMO.JOB"  ' default SQL stmt

 Text5 = ""
 Text6 = ""
 Text7 = ""
 Text8 = ""
 Text9 = ""
 Text10 = ""

End Sub

Private Sub OdbcTestX1_Click()

End Sub

Private Sub Text10_Change()

 OdbcTestX1.SetTranslateTable Text9, Text10

End Sub

Private Sub Text9_Change()

 OdbcTestX1.SetTranslateTable Text9, Text10

End Sub