我寫了這段代碼但是它沒有在數據庫中列出,會顯示消息是否成功插入?數據庫中沒有條目?但是,這個錯誤信息並沒有
if (txtdate.Text != "" && txtalireza.Text != "" && txtdatekamel.Text != "" && txthasan.Text != "" && txtkarbar.Text != "" && txtkarkard.Text != "" && txtkharid.Text != "" && txtmoj.Text != "" && txttozih.Text != "")
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Resources\dbcn.mdf;Integrated Security=True;User Instance=True");
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText="INSERT INTO newbuy(byname,datekol,dateshort,karkard,kharidha,b arali,barhasan,barmoj,descrip)VALUES(@byname,@date kol,@dateshort,@karkard,@kharidha,@barali,@barhasa n,@barmoj,@descrip)";
com.Parameters.AddWithValue("@byname",txtkarbar.Te xt);
com.Parameters.AddWithValue("@datekol", txtdatekamel.Text);
com.Parameters.AddWithValue("@dateshort", txtdate.Text);
com.Parameters.AddWithValue("@karkard",txtkarkard. Text);
com.Parameters.AddWithValue("@kharidha",txtkharid. Text);
com.Parameters.AddWithValue("@barali",txtalireza.T ext);
com.Parameters.AddWithValue("@barhasan",txthasan.T ext);
com.Parameters.AddWithValue("@barmoj",txtmoj.Text) ;
com.Parameters.AddWithValue("@descrip",txttozih.Te xt);
con.Open();
com.ExecuteNonQuery();
MessageBox.Show("inserted");
con.Close();
}
else
{ MessageBox.Show("error"); }`