Click here to Skip to main content
12,882,493 members (27,544 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
please help me how to bind Excel data into database in #-tier archietecture...

String strConnection = "Data Source=MySystem;Initial Catalog=MySamplesDB;Integrated Security=True";
        //file upload path
        string path = fileuploadExcel.PostedFile.FileName;
        //Create connection string to Excel work book
        string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
        ////Create Connection to Excel work book
        OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
        ////Create OleDbCommand to fetch data from Excel
        OleDbCommand cmd = new OleDbCommand("Select [Id],[Name],[Designation],[Address] from [Sheet1$]", excelConnection);
        OleDbDataReader dReader;
        dReader = cmd.ExecuteReader();
        SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
        //Give your Destination table name
        sqlBulk.DestinationTableName = "Excel_table";

this is the code in Single tier..
But i dont know how to convert this code into 3-tier please help me...
Posted 15-Oct-12 2:21am
Updated 15-Oct-12 3:55am
Wes Aday104.2K
aspnet_regiis -i 15-Oct-12 8:32am
What is a # tier application?
Wes Aday 15-Oct-12 9:56am
There is no conversion. You are confused on what a tier is and is not. You would simply put this code in your data access layer.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170422.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100