Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADO equivalent for NZ function in MS Access?

I have the following command object:

ADODB::_CommandPtr pCmd("ADODB.Command");

pCmd->ActiveConnection = pConn;
pCmd->CommandType = ADODB::adCmdText;
pCmd->CommandText = L" select ID, NZ(PaymentAmount, 0) from Contracts;";

ADODB::_RecordsetPtr pRS = pCmd->Execute(NULL, NULL, ADODB::adCmdText);

When I run it, it reports error that NZ function does not exists.

Researching on my own, I have found out that I can not use NZ in ADO queries.

QUESTION:

Is there ADO equivalent to this function?

like image 451
AlwaysLearningNewStuff Avatar asked Feb 11 '23 22:02

AlwaysLearningNewStuff


2 Answers

Use an IIf expression which produces the same result as Nz.

select ID, IIf(PaymentAmount Is Null, 0, PaymentAmount) As nz_PaymentAmount
from Contracts;
like image 60
HansUp Avatar answered Feb 13 '23 14:02

HansUp


Use IIF together with ISNULL function.

select ID, IIf(ISNULL(PaymentAmount), 0, PaymentAmount) As nz_PaymentAmount
from Contracts;
like image 27
Maciej Los Avatar answered Feb 13 '23 12:02

Maciej Los