c# - String or binary data would be truncated. The statement has been terminated.(Linq to SQL) -
i read topics related title question, in articles found error occurred when save maximum characters data in column. apply solution error not resolved. comment code guess maximum characters saved still faced problem. don't know why. below code. please help.
protected void btninsert_click(object sender, eventargs e) { try { sitedatacontext dc = new sitedatacontext(); user obj = new user(); obj.name = txtname.text.tostring(); obj.fathername = txtfathername.text.tostring(); obj.password = txtpassword.text.tostring(); obj.dob = txtdob.text.tostring(); obj.email = txtemail.text.tostring(); //for picture string filename = path.getfilename(fupicture.filename); fupicture.saveas(server.mappath("pictures/" + filename)); string address = ("pictures/" + filename).tostring(); obj.picture = address; obj.gender = rblgender.selecteditem.text.tostring(); obj.mobile = txtmobile.text.tostring(); obj.interest = getinterest(); dc.users.insertonsubmit(obj); dc.submitchanges(); lblmessage.visible = true; lblmessage.text = "data inserted successfully.... redirect login page in 5 seconds"; response.redirect("login.aspx"); } catch (exception exp) { lblmessage.visible = true; lblmessage.text = exp.message; } }
this error occurs if try save string database longer allowed database. all. fix it.
either limit input length, or adjust allowed length in database. not consider database irrelevant not publish table structure.
Comments
Post a Comment