Last post Jun 29, 2017 07:35 PM by strangermike
Jun 27, 2017 05:09 PM|StrangerMike|LINK
How can I create an Excel or CSV file in VB.net from a SQL Query in a web application?
I once did it from Access, but I can't figure how to do in SQL.
Thanks for your help
Here is how I did it with Access.
Dim NewConnection As New OleDbConnection
NewConnection.ConnectionString = ConfigurationManager.ConnectionStrings("MyConnection").ConnectionString
'New sheet in Workbook
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Excel 8.0;DATABASE=c:\Bank\OutStanding" & Me.Session("ReconDate") & ".xls;HDR=NO;].[Sheet1] from [tblOutStandChecks]", NewConnection)
But how with SQL Server?
Jun 27, 2017 09:19 PM|Nataraj Gandhi Arunachalam|LINK
Please refer to the below post which explains about sql query to export result to excel. If the queries work, You can try writing a stored procedure and calling it from your application.
Jun 28, 2017 05:39 AM|Eric Du|LINK
According to your description, as far as I know, you could try the following steps:
1. Select data from the database in Ado.net.
2. populate the gridview with the selected data.
3. export the gridview to excel or CSV file.
For more details, please refer to the following tutorials:
Export GridView to Excel in ASP.Net with Formatting using C# and VB.Net:
Export GridView To WordExcelPDFCSV in ASP.Net:
Jun 29, 2017 07:28 PM|StrangerMike|LINK
Thanks for information.
Jun 29, 2017 07:35 PM|StrangerMike|LINK
thank for information.