Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

i am getting the below error in my try catch block
VB
Try
           If para_name.Count = para_val.Count Then
               cmd = New SqlCommand(sp_name, cn)
               cmd.CommandType = CommandType.StoredProcedure
               For i = 0 To para_name.Count - 1
                   cmd.Parameters.AddWithValue(para_name(i), para_val(i))
               Next
               cmd.ExecuteNonQuery()
           Else
               MsgBox("Fill All Parameter....")
           End If
       Catch ex As Exception
       End Try

Error converting data type nvarchar to decimal.
i don't have any column with datatype nvarchar..please tell me what is the problem..

below is the SP wrote for it:
SQL
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[Add_salary]
	(
	
	@month_no varchar (50),
	@s_year int ,
	@emp_code int ,
	@basic numeric(18, 0),
	@da numeric(18, 0),
	@hra numeric(18, 0),
	@ca numeric(18, 0),
	@bp numeric(18, 0),
	@outfit numeric(18, 0),
	@bonus numeric(18, 0),
	@overseas numeric(18, 0),	
	@gross numeric(18, 0),
	@tot_ded numeric(18, 0),
	@netsal numeric(18, 0),
	@remark varchar(50)
	)	
AS
	insert into Salary (month_no,s_year,emp_code,basic,da,hra ,ca,bp,outfit,bonus,overseas,gross,tot_ded,netsal,remark) 
    values (@month_no,@s_year,@emp_code,@basic,@da,@hra ,@ca,@bp,@outfit,@bonus,@overseas,@gross,@tot_ded,@netsal,@remark)
	RETURN
Posted
Updated 30-Sep-12 23:11pm
v4
Comments
Chris Maunder 29-Sep-12 6:36am    
It's probably an issue with the stored proc you're calling. Please update your question and add the code for the sproc so we can help
HackensackNJ 29-Sep-12 6:38am    
Where is the stored procedures? If you can do convert(decimal, [column]) on the stored procedure this will be the best option for now.

Try this on your stored procedure

CAST(([yourcolumn]) AS DECIMAL(12,8))
 
Share this answer
 
Hi snehasish nandy,

Here the user don,t Know Sal as a Number(Basically they consider Decimal For exe : 105.50, )
after calculating Da,Ta it will get the Decimal so that it is raising an error.
So that you can declare all Currency(Money ) related fields as Decimal.

Note : Generally DA,TA, Allowances,.... gives % upon Basic Salary .Suppose Basic Salary
not multiplier of 100/10 it will get fractions like Decimal .


i hop you will get an idea Now.
 
Share this answer
 
Comments
[no name] 1-Oct-12 5:38am    
@Unareshraju: same error i m getting
Error converting data type nvarchar to int.
changed the datatype also but still it's comming
Unareshraju 1-Oct-12 5:51am    
instead of numeric(18, 0) change into Decimal(18,2) and
instead of varchar (50) change into nvarchar(50) after that
give like this

values ('@month_no',@s_year,@emp_code,@basic,@da,@hra ,@ca,@bp,@outfit,@bonus,@overseas,@gross,@tot_ded,@netsal,'@remark')

Note: nvarchar should in singlecote

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900