ارور درج در اسکیو ال و سی شارپ
]چرا این کدی که من نوشتم در همون لحظه که داده ها را درج میکنم در data gridwive نشون میده ولی در بانک ذخیره نمی کنه با ید چی کار کنم:13:
کد:
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\Database1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
DataSet ds =new DataSet();
if (txtfname.Text == "" || txtlname.Text == "" || txtcodozv.Text == "")
{
MessageBox.Show("يں©§ è©§ë ک§ مàيی¢ ، ëںê ي ëںê ¦ںëيں§گï ںéھںêï êï ں¬§");
}
conn.Open();
cmd.CommandText = "INSERT INTO aza(codeozviat,fname,lname,namepedar,tarikhtavalod,shomaremeli,telephon,address,tarikhozviat,tarikhengheza) VALUES( N'" + txtcodozv.Text + "',N'" + txtfname.Text + "',N'" + txtlname.Text + "',N'" + txtnamepedar.Text + "','" + mtxttarikhtavalod.Text + "'," + Convert.ToInt32(txtmeli.Text) + "," + Convert.ToInt32(txttelephon.Text) + ",N'" + txtaddress.Text + "','" + mtxttarikhozviat.Text + "','" + mtxttarikhengheza.Text + "')";
cmd.Connection = conn;
cmd.ExecuteNonQuery();
conn.Close();
}