Hi ,
Check this Example will Guide you it's easy
DataTable GetData(int id)
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(Properties.Settings.Default.con))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("select * from test where id = @id",con))
{
cmd.Parameters.AddWithValue("@id", id);
SqlDataAdapter adpt = new SqlDataAdapter(cmd);
adpt.Fill(dt);
}
}
return dt;
}
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = GetData(Convert.ToInt32(txtId.Text));
txtName.DataBindings.Add("Text", dt, "name");
}
Best Regards
M.Mitwalli