Click here to Skip to main content
13,199,680 members (67,837 online)
Click here to Skip to main content
Add your own
alternative version


162 bookmarked
Posted 19 May 2010

Database Export Wizard for ASP.NET and SQL Server

, 20 May 2010
Rate this:
Please Sign up or sign in to vote.
A step wizard for ASP.NET to export database objects to CSV, TXT, HTML, XML, or SQL

Table of Contents


With this article, I would like to share a simple but useful little tool: ExportWizard, a Step Wizard for Database Export.

It guides users through a few simple steps to choose a database object (table, view, or query), select columns, and export the data in any of the standard formats CSV, HTML, XML, or SQL.

The UI: 3 Simple Steps

The task of exporting from a database can be broken down as follows:

  1. Select a source database object (table, view, or query)
  2. Select columns to include in the export
  3. Select the export format (CSV, HTML, XML, SQL...)

These simple sequential tasks are a good fit for a step wizard.

The implementation discussed in this article is a web control, so the screenshots below are inside a web browser. It could be coded as a desktop application as well with the same basic elements and the same steps arrangement.

Step 1: Choose Data Source

Select table, view or SQL query to export data from.

Step 2: Select Columns to Include

Select columns to include in the export and sorting options.

Step 3: Choose Export Format and Options

This last step is for selecting the export format and options.

Different options for each format (with a little JavaScript to dynamically switch option panel without posting the page):

CSV, TXT, Excel
Options: Header and Separator


Options: Root element, attributes/elements format

Options: Colors


Options: Transaction, identity

Using the Web Control

The code is encapsulated as a web control (written in VB.NET) for ASP.NET and SQL Server. It is fully integrated with Visual Studio and its WYSIWYG designer. Just drag & drop to embed the control into your page.

Web Control Properties

(Design Time only)
Enables you to get a WYSIWYG display of any step during design time.
DHTMLenabledDetermines if user can show and hide options.

Introductory text for each step. Suggested values:
HeaderStep1 ="Please, select the data source to export."
HeaderStep2 ="Select columns to exports."
HeaderStep3 = "Select Output and format options."

SourceObjectProperty used to limit the possible tables or views from which to export. Comma-separated list of database objects.
SourceColumnsComma-separated list of columns to be selected by default.
Example: SourceColumns="ID,name,title"
SqlConnectionConnection string to the database, for example:

Index of the step currently displayed.

  1. step1_Source
  2. step2_SourceDetails
  3. step3_OutputType
  4. step4_Export

At design time, DesignStep allows users to view each step.


ExportWizard provides one event Show.


Triggered on display. Events arguments are the wizard current Title and StepIndex.

ShowEventArgs: Title As String, StepIndex As Integer


GetExport: Returns the database export as a String.
Example: GetExport("Contact", "Firstname, Lastname, PhoneW, email", "HTML")


Table or View from which to export.

ColumnsList of columns to export.
Possible value: Columns="ID,name" or Columns="*"

Format in which to export.
Possible values: CSV, HTML, SQL, TXT, or XML.

In addition, standard properties inherited from System.Web.UI.WebControls.WebControl applies.

Embedding the Control into the Page

To embed the control, copy the control DLL into the bin directory of your web application and add two lines of code to your page. The first line registers the control tag prefix (place this at the top of the page):

<%@ Register TagPrefix = "EVOL" Namespace = "Evolutility.ExportWizard" 

	Assembly = "Evolutility.ExportWizard" %> 

The second line embeds the control. Place the line anywhere within the page:

<EVOL:ExportWizard id= "ExportWizard1" runat = "server" 

	SqlConnection = "Server=(local);Database=Demo;Trusted_Connection=yes;" 	 


About the Code

Many developers or database administrators have written code to export from a database before (very likely you too if you are reading this article). This web control is written in VB.NET and is not intended to scale, but it does the job with small database tables.

To populate the dropdowns with the list of tables and views, or the list of columns, the technique I used was to query SQL Server system tables directly.

  • sysobjects (contains names of tables, views, stored procedures, and triggers)
  • syscolumns (contains column and stored procedure parameter names)
  • systypes (contains column types as displayed in Enterprise Manager)

The database user must have access to these system tables. These tables can also be used to generate database design documents as discussed in another article.


This web control is a stand-alone Web control. I have also used a modified version of it (in C#) integrated as a feature of Evolutility CRUD framework available on Get Evolutility at


  • 19th May, 2010: Initial post


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
I'm a UI engineer for a startup in California. What I really enjoy is to build tools to describe UI in metadata, store that metadata (outside of the code) in a database, XML or JSON, and then dynamically generate the UI at run-time based on that metadata... which I do with my open source project Evolutility.

My articles on the topic:

My GitHub is Evoluteur.

You may also be interested in...


Comments and Discussions

QuestionNew and improved version with preview feature Pin
Olivier Giulieri23-Sep-14 21:03
memberOlivier Giulieri23-Sep-14 21:03 
GeneralMy vote of 4 Pin
jacksparrow_4725-Aug-13 7:50
memberjacksparrow_4725-Aug-13 7:50 
QuestionError Pin
BinaryMadness5-Aug-13 5:07
memberBinaryMadness5-Aug-13 5:07 
AnswerRe: Error Pin
Nghia Do11-Oct-13 13:19
memberNghia Do11-Oct-13 13:19 
QuestionHyperlink when export Pin
Nghiado7731-Jul-13 19:58
memberNghiado7731-Jul-13 19:58 
AnswerRe: Hyperlink when export Pin
Olivier Giulieri5-Aug-13 18:00
memberOlivier Giulieri5-Aug-13 18:00 
Questiongood article Pin
Member 1000056625-Jun-13 1:17
memberMember 1000056625-Jun-13 1:17 
GeneralRe: good article Pin
Olivier Giulieri5-Aug-13 17:55
memberOlivier Giulieri5-Aug-13 17:55 
GeneralMy vote of 4 Pin
Akshay Jani23-Jun-13 21:08
memberAkshay Jani23-Jun-13 21:08 
GeneralRe: My vote of 4 Pin
Olivier Giulieri5-Aug-13 17:55
memberOlivier Giulieri5-Aug-13 17:55 
GeneralMy vote of 5 Pin
artefakt947-Jun-13 5:41
memberartefakt947-Jun-13 5:41 
GeneralRe: My vote of 5 Pin
Olivier Giulieri7-Jun-13 16:21
memberOlivier Giulieri7-Jun-13 16:21 
QuestionNice with small data set Pin
stefanveliki23-Apr-13 5:22
memberstefanveliki23-Apr-13 5:22 
AnswerRe: Nice with small data set Pin
Olivier Giulieri24-Apr-13 18:27
memberOlivier Giulieri24-Apr-13 18:27 
AnswerRe: Nice with small data set Pin
Nghia Do11-Oct-13 13:32
memberNghia Do11-Oct-13 13:32 
GeneralMy vote of 5 Pin
Phat (Phillip) H. VU13-Jan-13 21:56
memberPhat (Phillip) H. VU13-Jan-13 21:56 
GeneralRe: My vote of 5 Pin
Olivier Giulieri14-Jan-13 20:00
memberOlivier Giulieri14-Jan-13 20:00 
GeneralAbout Article Pin
prashant patil 498727-Dec-12 21:49
memberprashant patil 498727-Dec-12 21:49 
GeneralRe: About Article Pin
Olivier Giulieri28-Dec-12 23:23
memberOlivier Giulieri28-Dec-12 23:23 
GeneralMy vote of 5 Pin
csharpbd20-Nov-12 20:02
membercsharpbd20-Nov-12 20:02 
AnswerRe: My vote of 5 Pin
Olivier Giulieri20-Nov-12 20:20
memberOlivier Giulieri20-Nov-12 20:20 
GeneralMy vote of 5 Pin
Md. Marufuzzaman16-May-12 7:12
mentorMd. Marufuzzaman16-May-12 7:12 
GeneralRe: My vote of 5 Pin
Olivier Giulieri20-Nov-12 20:21
memberOlivier Giulieri20-Nov-12 20:21 
GeneralRe: My vote of 5 Pin
Md. Marufuzzaman21-Nov-12 5:00
mentorMd. Marufuzzaman21-Nov-12 5:00 
QuestionMy 5 Pin
MarkDaniel5-Jan-12 13:07
memberMarkDaniel5-Jan-12 13:07 
GeneralRe: My 5 Pin
Olivier Giulieri17-Feb-12 8:12
memberOlivier Giulieri17-Feb-12 8:12 
Questionwizard steps + sql server DB Pin
Lakoyana23-Sep-11 3:14
memberLakoyana23-Sep-11 3:14 
AnswerRe: wizard steps + sql server DB Pin
Olivier Giulieri25-Sep-11 19:54
memberOlivier Giulieri25-Sep-11 19:54 
QuestionMy Vote of ZERO Pin
Dewey26-Jul-11 14:16
memberDewey26-Jul-11 14:16 
<b>Plus 5 = FIVE!!!</b>

This is an AWESOME Article and Project!

I'm getting immediate use of this code!

Now, it's not perfect, and I'll probably add a little piect to change the connection string, but that's really minor.

Great Job!
AnswerRe: My Vote of ZERO Pin
Olivier Giulieri24-Dec-11 21:09
memberOlivier Giulieri24-Dec-11 21:09 
GeneralMy vote of 5 Pin
pingle19-Jul-11 17:42
memberpingle19-Jul-11 17:42 
GeneralRe: My vote of 5 Pin
Olivier Giulieri24-Dec-11 21:10
memberOlivier Giulieri24-Dec-11 21:10 
GeneralMy vote of 5 Pin
v_stupino1-Jul-11 5:47
memberv_stupino1-Jul-11 5:47 
GeneralRe: My vote of 5 Pin
Olivier Giulieri24-Dec-11 21:10
memberOlivier Giulieri24-Dec-11 21:10 
GeneralEvolutility.ExportWizard.GetExport Pin
Member 43676219-Oct-10 11:54
memberMember 43676219-Oct-10 11:54 
GeneralMy vote of 5 Pin
Anurag Gandhi29-Jul-10 4:57
memberAnurag Gandhi29-Jul-10 4:57 
GeneralMy vote of 5 Pin
ravi1234ravi16-Jul-10 19:07
memberravi1234ravi16-Jul-10 19:07 
QuestionNo data to export Pin
Julien Bolduc5-Jul-10 10:12
memberJulien Bolduc5-Jul-10 10:12 
GeneralFantastic Pin
dbullen21-Jun-10 23:54
memberdbullen21-Jun-10 23:54 
GeneralRe: Fantastic Pin
Olivier Giulieri22-Jun-10 3:12
memberOlivier Giulieri22-Jun-10 3:12 
QuestionCan we use this control for Windows Forms? Pin
Viji Raj9-Jun-10 9:17
memberViji Raj9-Jun-10 9:17 
GeneralExcellent Pin 22:20 22:20 
GeneralConnecting to other Database [modified] Pin
Business Consulting26-May-10 3:54
memberBusiness Consulting26-May-10 3:54 
GeneralRe: Connecting to other Database Pin
Evoluteur27-May-10 7:24
memberEvoluteur27-May-10 7:24 
GeneralExcellent Pin 4:40 4:40 
GeneralNice Control Pin
Brij24-May-10 2:49
mentorBrij24-May-10 2:49 
RantRe: Nice Control Pin
Xiaosheng Wang25-May-10 2:19
memberXiaosheng Wang25-May-10 2:19 
GeneralSleek! Pin
Sandeep Mewara20-May-10 19:34
mentorSandeep Mewara20-May-10 19:34 
GeneralExcellent Article Pin
linuxjr20-May-10 12:03
memberlinuxjr20-May-10 12:03 
GeneralAwesome Pin
Marcelo Ricardo de Oliveira20-May-10 9:08
memberMarcelo Ricardo de Oliveira20-May-10 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 20 May 2010
Article Copyright 2010 by Evoluteur
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid