Hi All,

i am trying to copy the data from a connection to a database directly to a new excel worksheet. Not having much luck but this is what i have so far:

VB Code:
  1. da = New SqlClient.SqlDataAdapter("select * from myTable", sqlConn)
  2.             da.Fill(dsICheck, "CDetails")
  3.  
  4.             'Create a new workbook in Excel.
  5.             Dim xlApp As New Excel.Application
  6.             Dim xlBook As New Excel.Workbook
  7.             Dim xlSheet As New Excel.Worksheet
  8.  
  9.             xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
  10.             xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
  11.             xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
  12.  
  13.             xlSheet.Application.Visible = True
  14.  
  15. 'here is where i come unstuck!
  16. 'i need to copy the rows from dsICheck to test.xls
  17.  
  18.             xlSheet.SaveAs("C:\test.xls")

Any help appreciated