TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
b b
NA
53
0
How to select Columns from excel sheet
Dec 13 2010 5:32 AM
Hi All,
I want to select few columns from Excel Sheet to datatable(not whole Excel sheet) using C# .net. Can anyone help me.
OleDbConnection connection = null;
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + @"F:\Book.xls" + ";" + "Extended Properties=Excel 8.0;";
DataTable dtCH = new DataTable();
connection = new OleDbConnection(sConnectionString);
OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);
connection.Open();
dtCH = new DataTable("Table");
OleDbDataReader db_reader = command.ExecuteReader();
dtCH.Load(db_reader);
DataTable table = dtCH;
connection.Close();
I am using the above codes and its shoeing all values from Excel file to Datatable. But i want to show only few columns from Excel to Datatable.
Regards,
B
Reply
Answers (
3
)
how to upload image in gridview through database in asp.net
microsoft visual basic error