ببین یه مثال بزنم برات:
if (txtfamily.Text != "" && txtname.Text != "")
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=dbmatabb;Integrated Security=True");
SqlCommand com = new SqlCommand();
con.Open();
com.Connection = con;
com.CommandText = "INSERT INTO bimeh (name,family)VALUES(@name,@family)";
com.Parameters.AddWithValue("@name",txtname.Text);
com.Parameters.AddWithValue("@family", txtfamily.Text);
com.ExecuteNonQuery();
con.Close();
MessageBox.Show("ثبت شد".ToString());
}
else
{
label3.Text = "لطفا همه فیلدهازاپر کنید".ToString();
}
مشکل داشتی همین جا بگو