Hello,
I am trying to pass some Table valued parameters to a stored procedure. I created the type like:
CREATE TYPE [dbo].[TestTableType] AS TABLE(
[Date] [date] NULL,
[Ref] [varchar](50) NULL,
[Amount] [decimal](20, 4) NULL
)
GO
I passed the parameter to the stored procedure by the following code:
Create PROCEDURE [dbo].[TestProcedure]
(@tvp dbo.TestTableType READONLY)
AS
BEGIN
select * from @tvp;
END
I am passing the parameter to the procedure by the following portion of the code:
List<SqlParameter> paramList = new List<SqlParameter>();
SqlParameter tvpParam = new SqlParameter("@tvp", dr);
tvpParam.SqlDbType = SqlDbType.Structured;
paramList.Add(tvpParam);
Here, dr is a Data Reader which contains the data read from an Excel file. The data of the excel file is as bellow:
Ref Amount Date
dsasdfdsf 234.00 01/01/2014
sdfdsfdsf 567.00 01/01/2014
sdfdsfdsf 345.00 01/01/2014
sdfdsfdsf 3456.00 01/01/2014
It throws an exception when the stored procedure is executed. The exception is:
"Invalid numeric precision/scale"
I am sure that the exception is throws only because of the Date Field. Because, It works if I remove the date field from the excel file and the table valued type. I tried to use different formats of the date, even I converted the date datatype to varchar(50) in the table valued type but, it didn't work.
The problem is with the date field. Can anyone help me, please .....