|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Pass Oracle ADO data from VB6 to Excel
Is there a way to save ADO data directly to an excel spread sheet?
Tryiing to 1. use VB to do the query to oracle DB. 2. Save the resulting recordset to a new EXCEL spreadsheet (which can be open for the person to see). Is there an easy to do this? Thanks in advance |
|
#2
|
|||
|
|||
|
This works manually but I have to spell out every Oracle column to fill excel columln. How I dump the whole oracle row to a excel spread sheet?
How do I show the Oracle Column names? Code:
Dim rtnValue As String
Dim strReturn As String
Dim strSQL As String
Dim ado_rs As ADODB.Recordset
Dim o As Object
Dim Row As Integer
Dim strRange As String
Dim Rscolumn As Integer
Row = 1
Rscolumn = 0
Set o = CreateObject("excel.application")
strSQL= “Select Date as Date, part_number as P/N, Location as Station, etc from TblLocation”
If fnPassSQL(strSQL, ado_rs) Then
o.Visible = True
o.Workbooks.Add
While Not ado_rs.EOF
strRange = "A" & Row & ":A" & Row <------- it's so manual
o.sheets("sheet1").range(strRange).value = ado_rs(Rscolumn)
strRange = "B" & Row & ":B" & Row
o.sheets("sheet1").range(strRange).value = ado_rs(Rscolumn + 1)
Row = Row + 1
ado_rs.MoveNext
Wend
End If
|
|
#3
|
|||
|
|||
|
You can use the SQL*XL addin for Excel to do this for you. SQL*XL is an end-user tool to get data from databases directly into your Excel spreadsheet. You can pick your table and download the data or supply a SQL query string.
Info on SQL*XL can be found at www.oraxcel.com If you are looking for an automated solution you can use the SQL*XL API from within Excel. SQL*XL also supports macro recording so most of the code can be generated for you. By using VBA and SQL*XL you hide all the ADO and Excel difficulties. Gerrit-Jan Linker www.oraxcel.com (SQL*XL) |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Pass Oracle ADO data from VB6 to Excel |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|