AlwaysLearningNewStuff
AlwaysLearningNewStuff

Reputation: 3031

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?

Upvotes: 4

Views: 613

Answers (2)

Maciej Los
Maciej Los

Reputation: 8591

Use IIF together with ISNULL function.

select ID, IIf(ISNULL(PaymentAmount), 0, PaymentAmount) As nz_PaymentAmount
from Contracts;

Upvotes: 2

HansUp
HansUp

Reputation: 97131

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

select ID, IIf(PaymentAmount Is Null, 0, PaymentAmount) As nz_PaymentAmount
from Contracts;

Upvotes: 6

Related Questions