private void btnSearch_Click(object sender, EventArgs e)
{
if (searchtext.Text == "")
{
MessageBox.Show("Plese Inter Employee's ID you are searching for");
searchtext.Focus();
}
else
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Employees.mdb");
OleDbDataAdapter ad = new OleDbDataAdapter("select * from Employee where EmpID=@EmpID", con);
ad.SelectCommand.Parameters.Add("@EmpID", OleDbType.Integer);
ad.SelectCommand.Parameters["@EmpID"].Value = int.Parse(searchtext.Text);
DataSet ds = new DataSet();
ad.Fill(ds, "Emp");
DGV1.DataSource = ds.Tables["Emp"];
if (ds == null)
{
MessageBox.Show("not found!!");
}
else
{
MessageBox.Show("The Employee you are searching for is listed down, if you want to update the data click the arrow sign on the lift side of the record");
}
}
Meftah 0 Newbie Poster
DaveAmour 160 Mmmmmm beer Featured Poster
jnneson 13 Light Poster
DaveAmour 160 Mmmmmm beer Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
deltaitservices 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.