c#, error: String or binary data would be truncated.

error: String or binary data would be truncated.
The data for table-valued parameter "@AnalyteTVP" doesn't conform to the table type of the parameter.
The statement has been terminated.      0      

Create TYPE [dbo].[TVP_AnalyteData] AS TABLE(
  [IDinAccess] char(7)
.
.
  , ReportingLevel decimal(16,8)    <---- please see  c5 below
)

-------------------------------------
c# code:
 string v1 = "";
if (temp != "")
        v1 = temp.Substring(0, temp.IndexOf("&nbsp;")).Trim();

 if (Decimal.TryParse(v1.Replace(",", ""), out number))
         c5 = number;
  else
         c5 = default(decimal?);

For @AnalyteTVP, see:
Create PROCEDURE [dbo].[sp_InsertLabAnalyteData] 
  @AnalyteTVP TVP_AnalyteData READONLY  

AS
BEGIN
--Select * From @AnalyteTVP;


-- multiple records of Anaylte data to AnalyteData table
 INSERT INTO dbo.LabAnalyteData (
  IDinAccess 
 .
.
  , ReportingLevel

 SELECT 
  IDinAccess 
 .
.
  , ReportingLevel
 FROM @AnalyteTVP;

Return @@Error

END

Here is LabAnalyteData table:

create table LabAnalyteData(
  labAnalyteID int identity
  , IDinAccess char(7)
.
.
  , ReportingLevel decimal(16,8)
)

Open in new window

LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Fernando SotoRetiredCommented:
The error you are getting is stating that the value you are sending to the database exceeds the range of value allowed in the database for the variable. In ReportingLevel decimal(16,8) the max size of the variable is x.y. Where x is a max of 8 digits and y is a max of 8 digits. Check to make sure you are not exceeding that limit.
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
I am processing about 1,500,000 rows. Only handful (about 10 rows) give me this error. I will locate these uncomfortable data after mt process ends. There is error table keeping a record of these rows for me to correct later.

I will keep you posted on the outcome.

Thanks,

Mike
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.