I am working on Updating information from a table using Sql Server, but I keep receiving the error "String or binary data would be truncated. The statement has been terminated." I have changed my maxlength of each textbox to equal the columns of my table but
keep receiving the same answer. I also increased the lengths to make sure there was enough space, but no successful ending. Can anyone help? Here is my code and error message. *************************************************************************** Sub
btnSubmit_Click( s As Object, e As EventArgs ) Dim strUpdate As String Dim cmdSelectData3 As SqlCommand Dim conMyData As SqlConnection conMyData = New SqlConnection("Server=helpdesk01; UID=sa; PWD=****; database=ASPState" ) cmdSelectData3 = New SqlCommand("MemberUpdate",
conMyData) cmdSelectData3.CommandType = CommandType.StoredProcedure cmdSelectData3.Parameters.Add("@MTitle", radMr.Text) cmdSelectData3.Parameters.Add("@First", trim(txtFirstname.text)) cmdSelectData3.Parameters.Add("@Middle", trim(txtMiddlename.Text)) cmdSelectData3.Parameters.Add("@Last",
trim(txtLastname.text)) cmdSelectData3.Parameters.Add("@Country", trim(dropCountry.SelectedItem.text)) cmdSelectData3.Parameters.Add("@Email", trim(txtEmail.text)) cmdSelectData3.Parameters.Add("@Promo", chkPromoUpdate.text) cmdSelectData3.Parameters.Add("@Genre",
trim(dropGenre.SelectedItem.text)) conMyData.Open() cmdSelectData3.ExecuteNonQuery() (**error in Red**) conMyData.Close() End Sub *************************************************************************
Naturally I can't be sure, since I'm not there, but it seems to me, that, at least one of the columns in the table is set for fewer characters than what is attempting to be inserted.
What is the Datatype of field Promo Are you trying to assign checkbox checked value or checkbox text value Similarly what is radMr?? is it radiobutton value?
In Enterprise manager assuming you have office installed in the box open the query analyzer and look in the Object browser. And take a look at the String functions, one of them will make your error go away. Run a search in the BOL(books online) for the
list below. Hope this helps.
cainioan
Member
120 Points
26 Posts
String or binary data would be truncated. The statement has been terminated.
Sep 30, 2004 03:04 PM|LINK
augustwind
All-Star
35860 Points
4900 Posts
ASPInsiders
Moderator
Re: String or binary data would be truncated. The statement has been terminated.
Sep 30, 2004 04:42 PM|LINK
All Things Dot Net
Stored Procs and Code in a Flash!
ASP.Net Sitemap Creator
SushilaSB
Star
11417 Points
2265 Posts
Re: String or binary data would be truncated. The statement has been terminated.
Oct 07, 2004 02:58 AM|LINK
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb
life's Ng
Contributor
2088 Points
432 Posts
Re: String or binary data would be truncated. The statement has been terminated.
Apr 29, 2005 02:23 AM|LINK
Hi, i encounting this problem while ago, i just change my column's length to higher, then it running well.
Cheers
life's Ng
Caddre
All-Star
26581 Points
5308 Posts
Re: String or binary data would be truncated. The statement has been terminated.
Apr 29, 2005 04:02 AM|LINK
In Enterprise manager assuming you have office installed in the box open the query analyzer and look in the Object browser. And take a look at the String functions, one of them will make your error go away. Run a search in the BOL(books online) for the list below. Hope this helps.
Gift Peddie