Based on the Exception Details you provided, it is not conclusive that the data coming from the Textbox6 control is the culprit of this error. There are 10 fields of data being passed to the INSERT statement, but the error simply claims that one of them 'could' be truncated (you are passing more data than one of the fields can accomodate).
But, if it is the Textbox6 field you are really worried about, you might should do a little 'validation' on that data before performing the INSERT statement. I mean, within the INSERT statement you are trying to 'convert' whatever is in that Textbox6 field to a DateTime data type. In the event someone types anything that is not a valid date ("John Doe", "Junuary 35, 2013", or even "05/42/1985"), this will cause an 'inner error' that is not trapped... and it leaves the INSERT statement (SQL) to handle it.
Possibly, you can use something similar to the following to help catch any flawed date values (or implement a RegEx to that Textbox6 control);
string dateFromText6 = TextBox6.Text;
DateTime dateParsed = new DateTime();
DateTime.TryParse(dateFromText6, out dateParsed);
if (dateParsed != new DateTime())
{
dateFromText6 = dateParsed.ToString();
}
else
{
dateFromText6 = DateTime.Now.ToString();
}
ctn.dmlsmt("insert into ShoppingCart values('" + ss1.bino + "','" + TextBox1.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox2.Text + "','" + TextBox5.Text + "','" + TextBox8.Text + "','" + TextBox7.Text + "','" + dateFromText6 + "'," + ss1.tprc + ")");
We are trying to better understand customer views on social support experience. Click HERE to participate the survey. Thanks!
Member
63 Points
79 Posts
Having a Problem with Inserting Date/DateTime data RSS
Jul 17, 2013 02:17 PM|anirudh_4sag|LINK
Please visit this link http://forums.asp.net/post/5456285.aspx
Member
180 Points
46 Posts
Re: Having a Problem with Inserting Date/DateTime data RSS
Jul 17, 2013 03:01 PM|CodeDog|LINK
I replied to that other post. I sure hope that helps.
Microsoft Certification ID: 9425425
https://www.mcpvirtualbusinesscard.com/VBCServer/CodeDog/interactivecard
Star
9903 Points
1291 Posts
Re: Having a Problem with Inserting Date/DateTime data RSS
Jul 18, 2013 10:52 PM|Pengzhen Song - MSFT|LINK
Hi,
I find that you have the solution in here http://forums.asp.net/t/1923070.aspx