Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ted Ted is offline
external usenet poster
 
Posts: 48
Default Trouble exporting ado rs to Excel

Hi, I am having trouble as a newbee. I am trying to export the dataset to
excel spread sheet. But I am unsure what the recordset object is called in
..net. Here is what I have so far:
Private Sub ExportToExcel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExportToExcel.Click
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add()
ws = wb.ActiveSheet()
ws.Range("A1").CopyFromRecordset

excel.Visible = True
wb.Activate()
'Catch ex As COMExceptionMessageBox.Show("Error accessing Excel:
" + ex.ToString())
'Catch ex As ExceptionMessageBox.Show("Error: " + ex.ToString())
Finally

End Try


End Sub

I appoligize but like I said I am new, Can anyone help me out. Thanks, Ted
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Trouble exporting ado rs to Excel

Ted,
The CopyFromRecordset method expects a recordset as an argument to copy
from. Check the Excel Help.
The recordset can be either ADO or DAO.
How you get that in .Net is up to you.

NickHK

"Ted" wrote in message
...
Hi, I am having trouble as a newbee. I am trying to export the dataset to
excel spread sheet. But I am unsure what the recordset object is called

in
.net. Here is what I have so far:
Private Sub ExportToExcel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExportToExcel.Click
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add()
ws = wb.ActiveSheet()
ws.Range("A1").CopyFromRecordset

excel.Visible = True
wb.Activate()
'Catch ex As COMExceptionMessageBox.Show("Error accessing

Excel:
" + ex.ToString())
'Catch ex As ExceptionMessageBox.Show("Error: " +

ex.ToString())
Finally

End Try


End Sub

I appoligize but like I said I am new, Can anyone help me out. Thanks,

Ted


  #3   Report Post  
Posted to microsoft.public.excel.programming
Ted Ted is offline
external usenet poster
 
Posts: 48
Default Trouble exporting ado rs to Excel

Nick thanks so much for answering but, the question is this. In VB 2005 what
is the recordset called? I mean, I have used the wizards to build my small
application and I did not have to write any ado code it was all written by
vb. So when I call ...copyfromrecordset (rs) It is the (rs) that I do not
know how to call in my appplication. I know this is a stupid question but I
appreciate the help.
Thanks again, Ted

"NickHK" wrote:

Ted,
The CopyFromRecordset method expects a recordset as an argument to copy
from. Check the Excel Help.
The recordset can be either ADO or DAO.
How you get that in .Net is up to you.

NickHK

"Ted" wrote in message
...
Hi, I am having trouble as a newbee. I am trying to export the dataset to
excel spread sheet. But I am unsure what the recordset object is called

in
.net. Here is what I have so far:
Private Sub ExportToExcel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExportToExcel.Click
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add()
ws = wb.ActiveSheet()
ws.Range("A1").CopyFromRecordset

excel.Visible = True
wb.Activate()
'Catch ex As COMExceptionMessageBox.Show("Error accessing

Excel:
" + ex.ToString())
'Catch ex As ExceptionMessageBox.Show("Error: " +

ex.ToString())
Finally

End Try


End Sub

I appoligize but like I said I am new, Can anyone help me out. Thanks,

Ted



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Trouble exporting ado rs to Excel

Ted,
In VB5/6 and VBA, you would:
Set a Project reference to "MS Active Data objects 2.x".
Then in a suitable location:
Dim Conn As ADODB.Connection
Dim RS as ADODB.RecordSet

Conn...Connect to your DB
Set RS=Conn.Excecute <SQLQuery

Assuming xlWS refers to a valid excel Worksheet
xlWS.Range("A1").CopyFromRecordSet RS

How you achieve that in .Net, I can't tell you.

NickHK

"Ted" ...
Nick thanks so much for answering but, the question is this. In VB 2005
what
is the recordset called? I mean, I have used the wizards to build my
small
application and I did not have to write any ado code it was all written by
vb. So when I call ...copyfromrecordset (rs) It is the (rs) that I do
not
know how to call in my appplication. I know this is a stupid question but
I
appreciate the help.
Thanks again, Ted

"NickHK" wrote:

Ted,
The CopyFromRecordset method expects a recordset as an argument to copy
from. Check the Excel Help.
The recordset can be either ADO or DAO.
How you get that in .Net is up to you.

NickHK

"Ted" wrote in message
...
Hi, I am having trouble as a newbee. I am trying to export the dataset
to
excel spread sheet. But I am unsure what the recordset object is
called

in
.net. Here is what I have so far:
Private Sub ExportToExcel_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles ExportToExcel.Click
Dim excel As Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ws As Microsoft.Office.Interop.Excel.Worksheet
Dim rng As Microsoft.Office.Interop.Excel.Range
Try
excel = New Microsoft.Office.Interop.Excel.Application
wb = excel.Workbooks.Add()
ws = wb.ActiveSheet()
ws.Range("A1").CopyFromRecordset

excel.Visible = True
wb.Activate()
'Catch ex As COMExceptionMessageBox.Show("Error accessing

Excel:
" + ex.ToString())
'Catch ex As ExceptionMessageBox.Show("Error: " +

ex.ToString())
Finally

End Try


End Sub

I appoligize but like I said I am new, Can anyone help me out. Thanks,

Ted





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
exporting to excel camri6 Excel Discussion (Misc queries) 3 December 4th 08 08:30 AM
Trouble Exporting Word Questionaire into Excel Patrick I Excel Worksheet Functions 0 February 21st 08 01:59 PM
Exporting from Excel Secret Squirrel Excel Discussion (Misc queries) 1 February 8th 06 03:37 PM
Exporting to Excel Grady Excel Discussion (Misc queries) 1 December 27th 05 07:24 AM
Trouble exporting chart to htm file - need help Jacson Excel Programming 3 January 10th 04 07:22 AM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"