Click here to Skip to main content
15,885,870 members
Articles / Database Development / SQL Server

Export a complete database to an Excel file

Rate me:
Please Sign up or sign in to vote.
4.76/5 (28 votes)
19 Mar 2008CPOL2 min read 106.6K   2.4K   85  
Export all tables and data to an Excel file.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Export complete database to Excel</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Table runat="server" ID="Table1" BorderStyle="Solid" >
        <asp:TableRow ID="TableRow0" runat="server" >
            <asp:TableCell ID="TableCell1" runat="server" ColumnSpan="2" HorizontalAlign="center" >
                <asp:Label ID="Label0" runat="server" Text="Export Complete database to Excel" Font-Size="Large" /><br /><br />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow ID="TableRow1" runat="server" >
            <asp:TableCell ID="TableCell2" runat="server" >
                <asp:Label ID="Label1" runat="server" Text="Database name:" />
            </asp:TableCell>
            <asp:TableCell ID="TableCell3" runat="server" >
                <asp:TextBox runat="server" ID="txtDatabase" />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow ID="TableRow2" runat="server" >
            <asp:TableCell ID="TableCell4" runat="server" >
                <asp:Label ID="Label2" runat="server" Text="Desired Filename :" />
            </asp:TableCell>
            <asp:TableCell ID="TableCell5" runat="server" >
                <asp:TextBox runat="server" ID="txtFilename" />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow ID="TableRow4" runat="server" >
            <asp:TableCell ID="TableCell8" runat="server" />
            <asp:TableCell ID="TableCell9" runat="server" ><br />
                <asp:Button runat="server" ID="btnCreate" Text="Create Excel file" OnClick="btnCreate_Click" />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow ID="TableRow5" runat="server" >
            <asp:TableCell ID="TableCell10" runat="server" ColumnSpan="2" >
                <asp:Label ID="lblResult" runat="server" />
            </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow ID="TableRow6" runat="server" >
            <asp:TableCell ID="TableCell11" runat="server" ColumnSpan="2" >
                <br /><hr />
                <asp:Label ID="Label4" runat="server" Text="This code has been written by Dennis Betten" /><br />
                <asp:Label ID="Label5" runat="server" Font-Bold="true"  Text="If you like it, be sure to rate it at www.CodeProject.com" /><br />
                <asp:HyperLink runat="server" NavigateUrl="http://www.codeproject.com/KB/vb/exportdatabasetoexcel.aspx" Text="http://www.codeproject.com/KB/vb/exportdatabasetoexcel.aspx" Target="_blank" /><br />
                <asp:Label ID="Label6" runat="server" Text="Thanx for downloading and enjoy using it!!" />
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior) Centric Netherlands
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions