Click here to Skip to main content
12,299,829 members (58,821 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);
        excelConnection.Open();
        OleDbDataReader dReader;
        dReader = cmd.ExecuteReader();
        SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
        //Give your Destination table name
        sqlBulk.DestinationTableName = "Excel_table";
        sqlBulk.WriteToServer(dReader);
        excelConnection.Close();

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
Edited 15-Oct-12 3:55am
Wes Aday104.2K
v3
Comments
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.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

try this code

check it[^]
may be this will help you
Thank You
Chetan V.
  Permalink  

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
Web02 | 2.8.160525.2 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2016
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