.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

String or binary data would be truncated

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

Hi Folks,

After I inserted a row in my Database (row 27) I started getting this error when I try to insert, update or delete the record in the database.

I've searched about the error on google and it says that I should have a field that crossed the limit of characters.

I have only the autoincrement field, two varchar fields and a text field, neither one of the varchar fields crossed the limit, they arent even close. I found in google that one solution would be turn the field that is having problems in a text field, but the only field that actually can be causing the problem already is of the text type.

The exact error I get on VS 2005 when trying to change something in the row 27 is:

"No row was updated.

The data in row 27 was not committed.
Error Source: .Net SqlClient Data Provider.
Error Message: String or binary data would be truncated.
The statement has been terminated.

Corret the errors and retry or press ESC to cancel the change(s)."

I need some help guyz, see ya, hugs.

View Complete Post

More Related Resource Links

ex {"String or binary data would be truncated. The statement has been terminated."}

Hello all,Please I have a Contact form which a user can use to send his or her message to the admin of a website. When all is done, he or she must click on submit button which in turn runs the code below.However, when this done the is an error ex    {"String or binary data would be truncated. The statement has been terminated."}. I would be grateful if someone could help me out to prevent the error.Thank you. Protected Sub txtSendMessage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSendMessage.Click Dim hdDataSource As New SqlDataSource() hdDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("hotelpauldbConnectionString1").ToString() hdDataSource.InsertCommandType = SqlDataSourceCommandType.Text hdDataSource.InsertCommand = "INSERT INTO contact (emailaddress, name, phone, reason, message) VALUES (@emailaddress, @name, @phone, @reason, @message)" hdDataSource.InsertParameters.Add("emailaddress", txtEmail.Text) hdDataSource.InsertParameters.Add("name", txtName.Text) hdDataSource.InsertParameters.Add("phone", txtPhone.Text) hdDataSource.InsertParameters.Add("reason", cmbReason.SelectedItem.Text) hdDataSource.InsertParameters.Add("message", txtMessage.Text) Dim

"String or binary data would be truncated" and field specifications

Hi all,   i have "String or binary data would be truncated" error when i try to execute an insert statment.   can i find witch field is affected by this error? (for return it to the user)   thank's all

Error Message: String or binary data would be truncated. The statement has been terminated




I have the following problem.

When I edit a field in the SQL Server Management Studio Express then I get the following error:

Error Source: .Net SqlClient Data Provider
Error Message: String or binary data would be truncated.

The statement has been terminated


When I use the SQL update commando, it works fine.

Fore debugging we need to change the enabled field several times.

Is there a solution fore this?



The Table Layout

USE [Project]


/****** Object: Table [dbo].[Proces] Script Date: 06/02/2008 10:01:20 ******/

String or binary data would be truncated.

I am getting this error message

String or binary data would be truncated.
The statement has been terminated.

I want to force this insert so that even if the column data length is less than the inserting value. it should still insert the
data as truncated ( or cut it short to fit the size of the column)

How do we achive this

String or binary data would be truncated



Below is my query

UPDATE StudentDetail
SET [Description]='TestTestTestTestTestTestTestTestTestTestTestTestTestTestTest',
WHERE StudentId=102

I get the following error while i execute it.

"String or binary data would be truncated."

Note:Both columns "Description" and "Value" are of type "nvarchar" and length=100

Can anyone help me to solve this...

String or binary data would be truncated


When the web form exceeds the number of  formated Strings (i.e., Zip Code, Phone Number, Fax Number, Email Address ); the submission is terminated. Error message reads: '[SqlException (0x80131904): String or binary data would be truncated.'

Go to the live web site at http://cforedu.com

Front code snippet reads:

      <asp:BoundField DataField="company" HeaderText="Company Name:" SortExpression="company" />
      <asp:BoundField DataField="position" HeaderText="Position Title:" SortExpression="position" />
      <asp:BoundField DataField="first" HeaderText="First Name:" SortExpression="first" />
      <asp:BoundField DataField="last" HeaderText="Last Name:" SortExpression="last" /&g

Error 8132:String or Binary data would be truncated. - Error only occurs when running execution of S

I have a Stored Procedure that I can execute from SQL Mgmt>New Query and running the exec statement and all is well. However, I have the same statement in a automated SQL Agent Job that the first step creates the Stored Procedure, second step executes Stored Procedure and then various other steps afterward. However, the job worked fine for a while and now the job dies at the second step each time. If I copy and paste the command for the second job in a new query manually, it works fine and the rest of the steps can process. Is this a bug?

Msg 8152, Level 16, State 14, Procedure HAM_User_Productive_Time, Line 20 String or binary data woul


I have this procedure and table architecture - My ultimate moto is to check the User Start time and user end time and if user is logged in into 2 pcs at once then capturing the min start time and max end time . If user start time is greater than users previous end time then creating a new entry into table.



Procedure dbo.HAM_User_Productive_Time





@Min Datetime

extract picture data from a string


dears,advance thanks.can anybdy help to solve my problem which is describing below.

Example- %%D1,100,0,0004[data...][0d0a]

Head - %%D1
Amount of data package -100
The data package No. - 0
Data Length -1024 (0004 (low bit in front, high bit in back) 0004= 0x0400=1024;)

data- Original Picture data -1024(maximum)
Tail -0x0d0a
Data in hex

from the above example i want to extract picture data and need to store in to the sql table.sql table columname is image and datatype is also image.after that i wanted to display this image column to an aspx page.

expecting help asap.

Create excel file from Binary data on SqlServer



My requirement is that i upload an excel file then i need to validate that data.


1. Uploading file using using upload control saving binary in SqlServer

2. Then i am creating file from binary data  on Sql Server using below command and then using OPENROWSET to dump data to Sql table

3. Then reading Sql Table row wise and validating data.


Alter Procedure spUploadExcelFile
  @PKID int,
  @BatchID int


	Declare @VarBin varbinary(max)
	Declare @FileName varchar(100)
	DECLARE @sql nvarchar(MAX)
                DECLARE @errMsg nvarchar(MAX)
	DECLARE @ObjectReturn INT
	DECLARE @ErrorSource VARCHAR(255)
	DECLARE @ErrorDesc VARCHAR(255)
	DECLARE @ObjectToken INT

	Select @VarBin  = Content , @FileName = [FileName] from MultilangBinaryData Where PKID = @PKID
	SET @FileName = 'C:\'  + @FileName
	EXEC sp_OACreate 'ADODB.Stream' @ObjectToken OUTPUT
	EXEC sp_OASetProperty @ObjectToken, 'Type', 1
	EXEC sp_OAMethod @ObjectToken, 'Open'
	EXEC sp_OAMethod @ObjectToken, 'Write', NULL, @VarBin
	EXEC sp_OAMethod @ObjectToken, 'SaveToFile', NULL, @FileName, 2
	EXEC sp_OAMethod @ObjectToken, 'Close'
	EXEC sp_OADestroy @ObjectToken  
	SET @sql = 'INSERT INTO dbo.UserBulkData SELECT 0,NULL,'+ @BatchI

Reading xml data from xml string




i have string like below:

<?xml version="1.0" encoding="utf-8" ?>










Data Conversion - string to datetime help!!!

Hi all, I need help on concatenate two fields into one then display it as datetime format as such yyyy-mm-dd hh:mm:ss AM/PM. The db is on SQL 2008 SP1. The date and time columns are on the same table and store as varchar. Date has varchar(10) and time has varchar(16). Date column shows result from query is 20100827 while the time column is either 070101.000000 or 070101. The question is how go about concatenate the two together and display in the format above in a report? How should I write my select query for this report? I am using SQL 2008 R2 BI Development Studio to design my report. Thank you. VCHS

How to store binary data as nvarchar(max)?

I’m trying to store a blob of binary data as nvarchar(max) and it gets truncated after just a few bytes. I wonder why and how can I prevent it. I don’t use varbinary(max) because I’m trying to keep existing DB schema intact. Current DB contains a huge chunks of text in nvarchar(max) column and I’m trying to compress (zip) this text and store it back to the same field to reduce DB size.   DB is accessed using Sync Framework (and Entity Framework) on the client side, so actual DB engine is SQL Server Compact 3.5 SP2   Thank you! KonstantinThank you! Konstantin

String Data missing start from "+" When Export Data To Excel Using Gridview

Hi,I am exporting data from gridview to excel file.My problem is that for all the string which contain "+", the rest of data begining from it is missing in excel file.For example: PWE-WER+78, when exported it will become PWE-WER.Below is my code.                Response.ClearContent() Response.Buffer = True Response.AddHeader("Content-Disposition", "attachment;filename=" & "ExportedExcel.xls") Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" lobjStringWriter = New StringWriter lobjHtmlWriter = New HtmlTextWriter(lobjStringWriter) dgdResult.RenderControl(lobjHtmlWriter) Response.Write(lobjStringWriter.ToString()) Response.End() I  have search through online but no solution.Does anyone has idea on this?

The maximum string content length quota (8192) has been exceeded while reading XML data.

Hi, I have been working on implementing a WCF service and have run into this problem with the maxStringContentLength.  I have read a bunch of posts here on how to correct it and none of them have worked.  I have updated my web.config in my local IIS5 published service to be maxStringContentLength="2147483647" and have updated my application's app.config to be maxStringContentLength="2147483647".  I delete all DLL's, rebuild, restart IIS, make sure all VS 2008 virtual webs are stopped, republish multiple times...even reboot my machine and I continually receive the following error message:The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/qlStatement. The InnerException message was 'There was an error deserializing the object of type System.String. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 171, position 35.'.  Please see InnerException for more details.I am running the service on my local machine: Win XP SP2, IIS5, .Net 3.5, VS 2008Here is my WCF service's servicemodel section of the web.config:    <system.serviceModel>    <bindings>      <wsHt

SQLBindparameter for binary sql data type.

How to use SQLBindparameter for binary data type of SQL? Please help and how to use SQLGetStmtAttr and SQLSetDescField for this?  Cheers!!! Vatsa
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend