Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Eghtebas

ASKER

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