Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
6
Answers
C# searching a Access Database
james james
7y
210
1
Reply
I have a Access database that i want to search by date my code returns nothing, what am I missing?
public
partial
class
MainWindow : Window
{
public
MainWindow()
{
InitializeComponent();
loadgrid();
txt_Date.Clear();
}
private
void
loadgrid()
{
OleDbConnection con =
new
OleDbConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings[
"Connection"
].ToString();
con.Open();
OleDbCommand cmd =
new
OleDbCommand();
cmd.CommandText =
"Select * from [Sheet1]"
;
cmd.Connection = con;
OleDbDataReader rd = cmd.ExecuteReader();
dataGrid.ItemsSource = rd;
}
private
void
btn_Search_Click(
object
sender, RoutedEventArgs e)
{
OleDbConnection con =
new
OleDbConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings[
"Connection"
].ToString();
con.Open();
OleDbCommand cmd =
new
OleDbCommand();
cmd.CommandText =
"Select * from Sheet1 WHERE ToDay like ('"
+ txt_Date.Text +
"%')"
;
cmd.Connection = con;
OleDbDataReader rd = cmd.ExecuteReader();
dataGrid.ItemsSource = rd;
loadgrid();
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
Microsoft.AspNet.SignalR.JS 2.2.2' to 'Microsoft.AspNet.Sign
Using return true and false