Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim con As New SqlConnection(WebConfigurationManager.ConnectionStrings("SQLConnectionString").ConnectionString) con.Open() Dim SQL = "select username,password,id from tbl_Login_Details " Dim Recordset = Server.CreateObject("ADODB.Recordset") Recordset.Open(SQL,con) 'Create a new workbook in Excel Dim oExcel As Object Dim oBook As Object Dim oSheet As Object oExcel = CreateObject("Excel.Application") oBook = oExcel.Workbooks.Add oSheet = oBook.Worksheets(1) 'Transfer the data to Excel oSheet.Range("A1").CopyFromRecordset(Recordset) 'Save the Workbook and Quit Excel oBook.SaveAs("C:\Book1.xls") oExcel.Quit() 'Close the connection Recordset.Close() con.Close() End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)