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
james james
NA
419
30k
C# searching a Access Database
Nov 3 2017 10:08 AM
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();
Reply
Answers (
6
)
Microsoft.AspNet.SignalR.JS 2.2.2' to 'Microsoft.AspNet.Sign
Using return true and false