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:
da = New SqlClient.SqlDataAdapter("select * from myTable", sqlConn) da.Fill(dsICheck, "CDetails") 'Create a new workbook in Excel. Dim xlApp As New Excel.Application Dim xlBook As New Excel.Workbook Dim xlSheet As New Excel.Worksheet xlApp = CType(CreateObject("Excel.Application"), Excel.Application) xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook) xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet) xlSheet.Application.Visible = True 'here is where i come unstuck! 'i need to copy the rows from dsICheck to test.xls xlSheet.SaveAs("C:\test.xls")
Any help appreciated![]()




Reply With Quote