If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Recordset.field.names with MS ODBC Driver for DB2 and MSDASQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-08-03, 06:58
Spyros Spyros is offline
Registered User
 
Join Date: Aug 2003
Posts: 1
Recordset.field.names with MS ODBC Driver for DB2 and MSDASQL

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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On