copy column headings from ADODB recordset

spyla

New Member
Joined
Jan 18, 2011
Messages
16
currently converting a workbook from excel2003 to excel 2010.

in excel 2003, xlodbc was used to get data from oracle

i am using ADODB to get data from Oracle

in excel 2003 the following command was used to paste data in to the spread sheet

Code:
SqlRetrieve Chan, Sheets("database").Range("fl_gas_fields_start"), 85, 2, True

this single line of code pastes Column names in one row and data in the Row below.

when I use the command below it just puts the values

Code:
Range("D6").CopyFromRecordset Rs1

VBA help gives the below example but is there any other way instead of looping through


Code:
For iCols = 0 to rs.Fields.Count - 1    
ws.Cells(1, iCols + 1).Value = rs.Fields(iCols).Name
Next
ws.Range(ws.Cells(1, 1),    
ws.Cells(1,rs.Fields.Count)).Font.Bold = True
ws.Range("A2").CopyFromRecordset rs
 
 


</PRE>




</PRE>
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,215,412
Messages
6,124,761
Members
449,187
Latest member
hermansoa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top