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
Caitlin Jojola
NA
1
815
Search entire excel workbook
Dec 19 2014 12:09 PM
I need help figuring out how to search my entire excel workbook. Below is the code to search one sheet from the workbook based on the text that the user enters. The results are displayed in a datagrid. Please help.
private void btSearch_Click(object sender, RoutedEventArgs e)
{
OleDbConnection con;
OleDbCommand cmd;
OleDbDataAdapter dap;
DataSet dat;
string cstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"C:\\Users\\Owner\\Documents\\Visual Studio 2013\\Projects\\ATSDBTest\\SampleDB.xlsx\";Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";
string sql = String.Format("select * from [Sheet1$] where (Name like '%{0}%')", txsearch.Text);
con = new OleDbConnection(cstr);
cmd = new OleDbCommand(sql, con);
dap = new OleDbDataAdapter(cmd);
dat = new DataSet();
dap.Fill(dat, "searchresults");
dg.DataContext = dat.Tables["searchresults"];
}
Reply
Answers (
0
)
Exe of WPF Application
Exe of WPF App