Sir, I am currently doing a project on "Pharmacy Management System". My question is "Can I used DataGridView to show the items that i have searched and the rest won't be visible??" If yes then can anyone give me the code for search button?? I have used the following code but its not working...please help ASAP....
private void button7_Click(object sender, EventArgs e)
{
txtsearch.Focus();
dataGridView1.Visible = true;
string connectionstring = "Data Source=DEBO-PC;Initial Catalog=Pharmacy;Persist Security Info=True;User ID=sa;Password=niit@123";
SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cm = new SqlCommand();
string search_text = "Select * from Stock_Details where Batch_Number like '%" + textBox1.Text + "%'" + "or Medicine_Name like '%" + textBox1.Text + "%'" + "or Mfg_Company like'%" + textBox1.Text + "%'";
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(search_text, con);
con.Open();
sda.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
con.Close();
}