Click here to Skip to main content
11,496,146 members (328 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: SQL-Server VB.NET
Hi all

i am getting the below error in my try catch block
           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))
               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:
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)
	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)
Posted 29-Sep-12 0:46am
Edited 1-Oct-12 0:11am
Chris Maunder at 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
CloudWebi at 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))
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.
snehasish nandy at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100