Quick console app with a function... that I can reuse
- codes with vb.net 2005 express version
- compatible with .net framework 2.0 and later
- compatible with sqlserver 2005 express and later
exportSQL2Excel(connectionString, sqlStatement, columnHeader, outputExcelFile, outputExcelSheet)
So what the function will do is:
a. connects to a SQL server based on connectionString, and retrieves a set of data based on sqlStatement.
b. write the the column headers, defined by columnHeader to the first row of outputExcelSheet of outputExcelFile.
c. write the retrieved set of data to the outputExcelSheet of outputExcelFile starting on second row.
So for the 5 arguments:
- connectionString: is a sqlserver connection string
- sqlStatement: is a select sql statement
- columnHeader: is a string of multiple column names separated by comma (,), and the column names may contain space (it is assumed that the column names listed in column Header will match what is being extracted by the sqlStatement).
- outputExcelFile: is a string of full path of location and name of an excel file
- outputExcelSheet: is name of an Excel Sheet (if it doesn't exist in outputExcelFile, then the function will create it as a new Sheet)
Skills: .net, visual-basic.net