Show mach data in datagridview by a textbox


Type a id in text box and click on the search

button it will show the mach data by the typed id

private void button1_Click(object sender, EventArgs e)

{

string se;

se = "select * from ja where id = @id";

SqlConnection con = new SqlConnection();

con.ConnectionString = "data source= Jbb-690ab60e108; Initial catalog = datamaster; Integrated security = true";

con.Open();

SqlCommand cmd = new SqlCommand();

cmd.Connection = con;

cmd.CommandText = se;

SqlParameter pp = cmd.Parameters.Add("@id", SqlDbType.VarChar, 10);

pp.Value = textBox1.Text;

SqlDataAdapter adapter = new

SqlDataAdapter(cmd);

DataTable dt = new DataTable();

adapter.Fill(dt);

{

dataGridView1.DataSource = dt;

}