开发者

How to set precision for adDecimal parameter to avoid "invalid precision" error?

开发者 https://www.devze.com 2023-04-06 08:52 出处:网络
I have a table on my MSSQL server with a column defined as decimal(8,2). From my c++ app I define the following parameter to be passed to the sp.

I have a table on my MSSQL server with a column defined as decimal(8,2).

From my c++ app I define the following parameter to be passed to the sp.

pParam1 = pCommand->CreateParameter ( 
_bstr_t ("Thing"),
adDecimal,          
adParamInput,
8,                  
(_variant_t) thing);
pCommand->Parameters->Append (pParam1);

I get an error "Invalid precision".

How do I开发者_如何学C have to define the precision in the pParam1 setup to make it match the definition in the table?


The default is (18,0). In VBScript it would be:

pParam1.Precision = 8
pParam1.NumericScale = 2

For C++ it is amazingly similar:

pParam1->Precision = 8;
pParam1->NumericScale = 2;


You have to subsequently set the Precison and NumericScale properties of the parameter object

0

精彩评论

暂无评论...
验证码 换一张
取 消