I am using vb and ado 2.7 to connect to an IBM DB2 database on a mainframe.
I use Msdatashape as provider, microsoft ole db provider for odbc (MSDASQL) as data provider and the odbc driver for IBM DB2 that comes with the MS HIS 2000.
In some DB2 tables I have written some column labels on some DB2 tables with the sql command:
Label on TABLE (column Col1 is ‘column description’)
My problem is that when I open a recordset with an sql select statement the field.names of the recordset get the column label and not the colum name.

Sample Code:
Set myDB = New adodb.Connection
myDB.Provider = "MSDataShape"
myDB.Properties("Data Source") = "MSODBC" ‘MS ODBC driver for the database
myDB.Properties("user ID") = “MyUserId”
myDB.Properties("Password") = “MyPassword”
myDB.Properties("Data Provider") = "MSDASQL"
Set rsA = New Recordset
Set rsA.ActiveConnection = myDB
rsA.LockType = adLockOptimistic
rsA.CursorType = adOpenKeyset
rsA.Source = "select Col1, Col2 from MYQU.MYTABLE ”
rsA.open

debug.print rsA.fields(1).name gives “column description” and not “Col1”

the problem does not fix even when I explicitly set the column name:
rsA.Source = "select Col1 as Col_1, Col2 as Col_2 from MYQU.MYTABLE ”
even then
debug.print rsA.fields(1).name gives “column description” and not “Col_1”


For Columns with no label specified the recordset.field.name is the same as the Column Name.

Is therer any way that the recordset returns always the column names as field names?


When I use the IBM odbc data source with the Microsoft ole db provider for odbc
myDB.Properties("Data Source") = "IBMODBC" ‘IBM ODBC driver for the database
myDB.Properties("Data Provider") = "MSDASQL"
the recordset.field.name is always the column name even when there is a column label in the DB2 table

This happens also when I use the Microsoft odbc driver with the IBM ole DB provider for DB2
myDB.Properties("Data Source") = "MSODBC" ‘MS ODBC driver for the database
myDB.Properties("Data Provider") = "IBMDADB2.1" ‘IBM OLE DB Provider for odbc

However I want to use only Microsoft products.
Can you help me please?