I have used rich text box to collect remarks but its not being saved in the database
here is the code
con.Open();
SqlCommand cmd = new SqlCommand(@"insert into Student_Records(FirstName,LastName,ContactNumber,DOB,TemporaryAddress,PermanentAddress,FatherName,Fathersoccupation,ContactNumberF,MotherName,Mothersoccupation,ContactNumberM,Remarks) values(@firstname,@lastname,@contactnumber,@dob,@temporaryaddress,@permanentaddress,@fathername,@fatheroccupation,@contactnumberf,@mothername,@motheroccupation,@contactnumberm,@remarks)", con);
cmd.Parameters.AddWithValue("@firstname", txtFname.Text);
cmd.Parameters.AddWithValue("@lastname", txtlastN.Text);
cmd.Parameters.AddWithValue("@contactnumber", txtCN.Text);
cmd.Parameters.AddWithValue("@dob", dtdob.Value);
cmd.Parameters.AddWithValue("@temporaryaddress", txtTaddress.Text);
cmd.Parameters.AddWithValue("@permanentaddress", txtPaddress.Text);
cmd.Parameters.AddWithValue("@fathername", txtFname.Text);
cmd.Parameters.AddWithValue("@fatheroccupation", txtFoccupation.Text);
cmd.Parameters.AddWithValue("@contactnumberf", txtFcn.Text);
cmd.Parameters.AddWithValue("@mothername", txtMname.Text);
cmd.Parameters.AddWithValue("@motheroccoupation", txtMoccupation.Text);
cmd.Parameters.AddWithValue("@contactnumberm", txtMcn);
cmd.Parameters.AddWithValue("@remarks", rtremarks.Rtf);
cmd.ExecuteNonQuery();
con.Close();
In this line
cmd.Parameters.AddWithValue("@contactnumberm", txtMcn);
you're passing the TextBox
itself, not its Text property.
Having said that, that will give a slightly different error. As noted in your other question about this piece of code, please post code and errors verbatim at the time you get the error, otherwise you may not get helpful answers. (Either that or you have named txtMcn
inconsistently!)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.