Error converting data type varchar to bigint..
I am Passing JSON Data to Service and trying to insert the binary data for the uploaded file by using Telerik RadUpload... and it shows ''Error converting data type varchar to bigint'' and it is inserting when I directly Passing the Values in Executing the Stored Procedure Directly with out any Error
USE [DB]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[InserID]
@Colum1= 1,
@Colum2= 1,
@Colum3= 1,
@Document= N'ICAgLy9Db21tYW5kRXZlbnRBcmdzIGUyID0gbmV3IENvbW1hbmRFdmVudEFyZ3MobnVsbCwgcmFkYnV0dG9uMS5Db21tYW5kQXJndW1lbnQpOw0KICAgICAgICAgICAgLy9UcmVlTGlzdENvbW1hbmRFdmVudEFyZ3MgZTEgPSBuZXcgVHJlZUxpc3RDb21tYW5kRXZlbnRBcmdzKG51bGwsIHJhZGJ1dHRvbjEuQ29tbWFuZEFyZ3VtZW50LCBlMik7DQogICAgICAgICANCiAgICAgICAgICAgIC8vSGFzaHRhYmxlIHRhYmxlID0gbmV3IEhhc2h0YWJsZSgpOw0KICAgICAgICAgDQogICAgICAgICAgICAvL1RyZWVMaXN0RWRpdEZvcm1JdGVtIGl0ZW0gPSBlMS5JdGVtIGFzIFRyZWVMaXN0RWRpdEZvcm1JdGVtOw0KICAgICAgICAgICAgLy9zdHJpbmcgdGl0bGUgPSAoaXRlbVsiUGFydHlQYXJlbnRSb3dJZCJdLkZpbmRDb250cm9sKCJUZXh0Qm94MSIpIGFzIExhYmVsKS5UZXh0Ow0KICAgICAgICAgICAgLy9UYWJsZUNlbGwgY2VsbCA9IGl0ZW1bIlBhcnR5UGFyZW50Um93SWQiXTsNCiAgICAgICAgICAgIC8vdGFibGVbIlBhcnR5UGFyZW50Um93SWQiXSA9IChpdGVtLkZpbmRDb250cm9sKCJUZXh0Qm94MSIpIGFzIFRleHRCb3gpLlRleHQ7DQogICAgICAgICAgICAvL3RhYmxlWyJQYXJ0eVJvd0lkIl0gPSAoaXRlbS5GaW5kQ29udHJvbCgiVGV4dEJveDIiKSBhcyBUZXh0Qm94KS5UZXh0Ow=='
SELECT 'Return Value' = @return_value
GO
and the Stored Procedure is...
ALTER Procedure[dbo].[InsertID]
(
@Column1bigint,
@Column2 bigint,
@Column3 bigint,
@Document varchar
)
AS
BEGIN
SET NOCOUNT OFF
SET XACT_ABORT ON
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO Table
(Column1,Column2,Colum3,Document)
VALUES
(@Column1,@Column2,@Column3, CONVERT(varbinary(max),@Document))
COMMIT
END TRY
and the code in the service is....
public string FunctionForID(Stream Model)//I passed the JSON Data With the values of Colum1 Colum2 Column3 and Document
{
string response = string.Empty;
try
{
StreamReader sr = new StreamReader(Model);
dynamic param = JsonConvert.DeserializeObject<dynamic>(sr.ReadToEnd());
SqlParameter[] parameters =
{
new SqlParameter("@Coulmn1", SqlDbType.BigInt) { Value = param.Coulmn1},
new SqlParameter("@Coulmn1", SqlDbType.BigInt) { Value = param.Coulmn1},
new SqlParameter("@Coulmn1", SqlDbType.BigInt) { Value = param.Coulmn1},
new SqlParameter("@Document", SqlDbType.VarChar) { Value = param.Document}
};
int result = Class.ExecuteNonQuery(null, CommandType.StoredProcedure, "InserID", parameters);
}
catch (Exception Err)
{
}
return response;
}
Sample of my JSON(with same values I passed in Stored Procudre )
{"Colum1":1,"Colum2":1,"Colum3":1,"Document":"ICAgLy9Db21tYW5kRXZlbnRBcmdzIGUyID0gbmV3IENvbW1hbmRFdmVudEFyZ3MobnVsbCwgcmFkYnV0dG9uMS5Db21tYW5kQXJndW1lbnQpOw0KICAgICAgICAgICAgLy9UcmVlTGlzdENvbW1hbmRFdmVudEFyZ3MgZTEgPSBuZXcgVHJlZUxpc3RDb21tYW5kRXZlbnRBcmdzKG51bGwsIHJhZGJ1dHRvbjEuQ29tbWFuZEFyZ3VtZW50LCBlMik7DQogICAgICAgICANCiAgICAgICAgICAgIC8vSGFzaHRhYmxlIHRhYmxlID0gbmV3IEhhc2h0YWJsZSgpOw0KICAgICAgICAgDQogICAgICAgICAgICAvL1RyZWVMaXN0RWRpdEZvcm1JdGVtIGl0ZW0gPSBlMS5JdGVtIGFzIFRyZWVMaXN0RWRpdEZvcm1JdGVtOw0KICAgICAgICAgICAgLy9zdHJpbmcgdGl0bGUgPSAoaXRlbVsiUGFydHlQYXJlbnRSb3dJZCJdLkZpbmRDb250cm9sKCJUZXh0Qm94MSIpIGFzIExhYmVsKS5UZXh0Ow0KICAgICAgICAgICAgLy9UYWJsZUNlbGwgY2VsbCA9IGl0ZW1bIlBhcnR5UGFyZW50Um93SWQiXTsNCiAgICAgICAgICAgIC8vdGFibGVbIlBhcnR5UGFyZW50Um93SWQiXSA9IChpdGVtLkZpbmRDb250cm9sKCJUZXh0Qm94MSIpIGFzIFRleHRCb3gpLlRleHQ7DQogICAgICAgICAgICAvL3RhYmxlWyJQYXJ0eVJvd0lkIl0gPSAoaXRlbS5GaW5kQ29udHJvbCgiVGV4dEJveDIiKSBhcyBUZXh0Qm94KS5UZXh0Ow=="}