ببین کارت با اینا راه می افته؟
SqlCommand com = new SqlCommand();
com.CommandText = "INSERT INTO t2 (name,famil)"
+"VALUES(@name,@famil)";
com.Parameters.AddWithValue("@name", textBox1.Text);
com.Parameters.AddWithValue("@famil", textBox2.Text);
com.Connection = con;
con.Open();
result = com.ExecuteNonQuery();
con.Close();
با این کد دیتا گرد ویو رو رفرش کن بعد هر بار اینزرت یا آپدیت یا ...
public void load()
{
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand();
sda.SelectCommand.Connection = con;
sda.SelectCommand.CommandText = "select * from t2";
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}