sql - Filling Excel Workbook from sqlserver HRESULT: 0x800401A8 error -
i trying fill excel sheet sql server database , getting message code
hresult: 0x800401a8
please assist me.
dim file string = "c:\techform.xlsx" dim xlapp_2 new excel.application xlapp_2.visible = false xlapp_2.displayalerts = false dim obook excel.workbook obook = xlapp_2.workbooks.open(file) dim osheet excel.worksheet osheet = obook.worksheets(1) objconnection.open() adapter_view.selectcommand = new sqlcommand() adapter_view.selectcommand.connection = objconnection adapter_view.selectcommand.commandtext = "select * technical_ams_calc_gargantua " adapter_view.selectcommand.commandtype = commandtype.text adapter_view.fill(dataset, "gargantua_average_data") datatable_calc = dataset.tables("gargantua_average_data") adapter_view.dispose() h integer = 0 datatable_calc.rows.count - 1 sog_avg = datatable_calc.rows(h).item("vpm_speed_through_water_avg") osheet.range("e3").value = datatable_calc.rows(h).item("vpm_speed_through_water_avg") osheet.range("f3").value = datatable_calc.rows(h).item("vpm_speed_through_water_max") obook.saveas(file + " " + datatable_calc.rows(h).item("action_date") + ".xlsx", createbackup:=false) obook.close() xlapp_2.quit() next
like this:
dim file string = "c:\techform.xlsx" dim xlapp_2 new excel.application xlapp_2.visible = false xlapp_2.displayalerts = false dim obook excel.workbook obook = xlapp_2.workbooks.open(file) dim osheet excel.worksheet osheet = obook.worksheets(1) objconnection.open() adapter_view.selectcommand = new sqlcommand() adapter_view.selectcommand.connection = objconnection adapter_view.selectcommand.commandtext = "select * technical_ams_calc_gargantua " adapter_view.selectcommand.commandtype = commandtype.text adapter_view.fill(dataset, "gargantua_average_data") datatable_calc = dataset.tables("gargantua_average_data") adapter_view.dispose() h integer = 0 datatable_calc.rows.count - 1 sog_avg = datatable_calc.rows(h).item("vpm_speed_through_water_avg") osheet.range("e3").value = datatable_calc.rows(h).item("vpm_speed_through_water_avg") osheet.range("f3").value = datatable_calc.rows(h).item("vpm_speed_through_water_max") next obook.saveas(file + " " + datatable_calc.rows(h).item("action_date") + ".xlsx", createbackup:=false) obook.close() xlapp_2.quit()
Comments
Post a Comment