I am using Stored Procedures to update tables or Insert into tables.
When working with local database (database in the same system and application also in the same system, No network or shared Database) all are working well without any errors.
My application is in Visual C#.
When I have converted the application to use in multiuser environment and used the same existing database with same stored Procedures with same values, and the same Sqlserver Express version, I have encountered the error
"Arithmetic overflow error converting numeric to data type numeric".
I have tried to limit the variables by declaring as a decimal with specified lengths and increased the table columns one decimal more than what I have declared in the stored procedure. But same error coming and unable to find the solution.
Is there any limitations with SQL server compared with local system database vs remote server database.
Both are same data, same values, same code, same application. Nothing changed except the connection string.
The stored procedure code am using is as below.
USE [inventoryDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF -- this is added now because in some place someone said that it will overcome the error.
GO
CREATE PROCEDURE [dbo].[SalesMainInsert]
(
@cblno INT=0,
@bldate DATETIME ='',
@rname VARCHAR(50)='',
@custname VARCHAR(50)='',
@custcode VARCHAR(50)='',
@smaname VARCHAR(50)='',
@mblno VARCHAR(50)='',
@bldis1per decimal(20,2)=0,
@bldis1amt decimal(20,2)=0,
@bldis2 decimal(20,2)=0,
@bldis3 decimal(20,2)=0,
@dis3narr VARCHAR(500)='',
@blcash BIT=0,
@billnet decimal(20,2)=0,
@bltax decimal(20,2)=0,
@addless decimal(20,3)=0,
@billtot decimal(20,3)= 0,
@rndval decimal(9,2)=0,
@blgross decimal(20,2)=0,
@remarks VARCHAR(50)='',
@TotalCessAmt decimal(20,3)=0,
@TotalAddlCessAmt decimal(20,3)=0,
@cstat AS BIT = 0,
@bstat AS VARCHAR(10)='',
@custtype AS VARCHAR(1)='',
@ReturnValue AS INT = 0 OUT
)
AS
BEGIN
INSERT INTO dbo.salesHDB
(
cblno,
bldate,
rname,
custname,
custcode,
smaname,
mblno,
bldis1per,
bldis1amt,
bldis2,
bldis3,
dis3narr,
blcash,
billnet,
bltax,
addless,
bltotal,
rndval,
blgross,
remarks,
TotalCessAmt,
TotalAddlCessAmt,
cstatus,
bstatus,
custtype
)
VALUES (
@cblno,
@bldate,
@rname,
@custname,
@custcode,
@smaname,
@mblno,
@bldis1per,
@bldis1amt,
@bldis2,
@bldis3,
@dis3narr,
@blcash,
@billnet,
@bltax,
@addless,
@billtot,
@rndval,
@blgross,
@remarks,
@TotalCessAmt,
@TotalAddlCessAmt,
@cstat,
@bstat,
@custtype
)
IF @@ERROR = 0
BEGIN
SET @ReturnValue = 1
END
ELSE
BEGIN
SET @ReturnValue = -1
END
END
What I have tried:
I Googled but failed to find any suitable solution