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
Israel
693
1.3k
219.4k
Make filter Between number
Feb 27 2017 2:21 AM
Hi!
With two comboboxes I need to make filter from one database column.
I wrote these codes to facilitate me to make filter between a couple of numbers. For instance, display number between 3 to 8.
I do try to write these codes but its doesnt works. Please have a look:
private void picBxAgeCons_Click(object sender, EventArgs e)
{
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from myDataBase where (Age between ? and ?)";
var param1 = new OleDbParameter("@StartAge", OleDbType.Numeric);
var param2 = new OleDbParameter("@EndAge", OleDbType.Numeric);
param1.Value = cbxAgeStart.Text;
param2.Value = cbxAgeEnd.Text;
if (cbxAgeStart.Text <= cbxAgeEnd.Text)
{
cmd.Parameters.Add(param1);
cmd.Parameters.Add(param2);
}
else
{
cmd.Parameters.Add(param2);
cmd.Parameters.Add(param1);
}
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
conn.Close();
dgvIdadeCons.DataSource = dt;
this.dgvIdadeCons.RowsDefaultCellStyle.BackColor = Color.AliceBlue;
this.dgvIdadeCons.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
}
Reply
Answers (
6
)
Barcode scanning application with Memory database
Dot net Project Link