Decimal数据格式
ALTER proc [dbo].[up_ExchangeEdit]
@ExchangeGuid uniqueidentifier,
@USDRate decimal (18,4),
@GBPRate decimal (18,4),
@EURRate decimal (18,4),
@HKDRate decimal (18,4),
@JPYRate decimal (18,4),
@CreatedBy varchar(50)
as
IF(EXISTS(SELECT 1 FROM dbo.T_Exchange trm WHERE trm.ExchangeGuid=@ExchangeGuid))
BEGIN
UPDATE dbo.T_Exchange
SET
ExchangeGuid=@ExchangeGuid,
USDRate=@USDRate ,
GBPRate=@GBPRate,
EURRate=@EURRate,
HKDRate=@HKDRate,
JPYRate=@JPYRate,
CreatedAt=GETDATE(),
CreatedBy=@CreatedBy
WHERE
ExchangeGuid=@ExchangeGuid
END
ELSE
BEGIN
INSERT INTO T_Exchange
(
ExchangeGuid,
USDRate ,
GBPRate,
EURRate,
HKDRate,
JPYRate,
CreatedAt,
CreatedBy
)
VALUES
(
@ExchangeGuid,
@USDRate ,
@GBPRate,
@EURRate,
@HKDRate,
@JPYRate,
GETDATE(),
@CreatedBy
)
END
public void EditExchange(Exchange exchange) { SqlParameter[] prams = { Database.MakeInParam("@ExchangeGuid", System.Data.SqlDbType.UniqueIdentifier, 16, exchange.ExchangeGuid), Database.MakeInParam("@USDRate", System.Data.SqlDbType.Decimal, 18, exchange.USDRate), Database.MakeInParam("@GBPRate", System.Data.SqlDbType.Decimal, 18, exchange.GBPRate), Database.MakeInParam("@EURRate", System.Data.SqlDbType.Decimal,18, exchange.EURRate), Database.MakeInParam("@HKDRate", System.Data.SqlDbType.Decimal, 18, exchange.HKDRate), Database.MakeInParam("@JPYRate", System.Data.SqlDbType.Decimal, 18, exchange.JPYRate), Database.MakeInParam("@CreatedBy", System.Data.SqlDbType.VarChar,50, exchange.CreatedBy) }; new SqlPlus().ExecuteNonQuery(CommandType.StoredProcedure, "up_ExchangeEdit", prams); } USDRate 是decimal(18,4)其中18表示数据长度,4表示保留4位小数