Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
c# code for how to insert total excel coloumn in database
Posted 26-Dec-12 23:39pm
Comments
Oleksandr Kulchytskyi at 27-Dec-12 5:54am
   
What do you mean ???
Total count of collumns on one sheet??
Or all columns (it's name )???
IpsitaMishra at 27-Dec-12 6:07am
   
I thought you want to insert all the column(and daterows) of excel sheet to one of the table in the your db .Is it :)

1 solution

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

Solution 1

Try this it may help you
string connectionString = GetConnectionString();
                        OleDbConnection connection = new OleDbConnection(connectionString);
                        connection.Open();
                        OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Sheet2$]", connection);
                        DataTable dtImprtExcel = new DataTable();
                        adapter.Fill(ds);
                        connection.Close();
 
after that use the table ds to fill your datatable
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 527
1 CPallini 510
2 Sergey Alexandrovich Kryukov 438
3 George Jonsson 271
4 Afzaal Ahmad Zeeshan 184
0 OriginalGriff 5,370
1 CPallini 4,360
2 Sergey Alexandrovich Kryukov 3,822
3 George Jonsson 3,037
4 Gihan Liyanage 2,435


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
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