无法使用c#将十进制值插入sql server [英] Unable to insert the decimal value into sql server using c#
本文介绍了无法使用c#将十进制值插入sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
create table tbl_Employee_payment(
Emp_id int foreign key references tbl_EmployeeMast(Emp_id),
paymentdate date,
Empl_name varchar(300),
designation varchar(100),
salary decimal(5,2),
advance_amnt decimal(5,2),
sale_of_month decimal(5,2),
bonus_amnt decimal(5,2),
payment_mode varchar(100),
payment_detail varchar(max),
payment_amnt decimal (4,3)
)
我的尝试:
插入tbl_Employee_payment值(1,'2016-02-09','javeer','sss',1000,355.00,11,111.00,'在线','转移',645)
What I have tried:
insert into tbl_Employee_payment values(1,'2016-02-09','javeer','sss',1000,355.00,11,111.00,'online','transfered',645)
推荐答案
朋友,
Hi Friend,
create table tbl_Employee_payment(
Emp_id int foreign key references tbl_EmployeeMast(Emp_id),
paymentdate date,
Empl_name varchar(300),
designation varchar(100),
salary decimal(16,2),
advance_amnt decimal(16,2),
sale_of_month decimal(16,2),
bonus_amnt decimal(16,2),
payment_mode varchar(100),
payment_detail varchar(max),
payment_amnt decimal (16,3)
)
在使用decimal数据类型的所有列中将小数范围更改为十进制(16,2)。希望这会有所帮助。谢谢..
Change your decimal range to decimal(16,2) in all columns where you are using decimal datatype . hope this will help. thanks..
示例插入语句可以运行没有问题。
可能你试图插入一个超过定义的数据类型的值可以在其他语句中处理。
小数(5,2)总共可以处理最多5位数(左+右)小数点的小数点)和小数点右侧的2位数。快速浏览一下:
小数和数字(Transact-SQL) [ ^ ]
-dp -
The example insert statement would have been run with no problem.
Probably, you were trying to insert a value which is more than the defined datatype can handle in some other statement.
A decimal(5,2) can handle maximum 5 digits in total (left + right side of the decimal point) and 2 digits to the right side of the decimal point. Have a quick look at:
decimal and numeric (Transact-SQL)[^]
-dp-
这篇关于无法使用c#将十进制值插入sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文