VB.NET – Unrecognized ‘=’ in SQL statement

I receive an error stating that the equal sign cannot be recognized. I always test my code in Access to make sure it works. Does anyone know why this is happening?

Code:

SELECT SUM(
IIf(TransactionType ='Cash',
TotalPrice, 0)< br />) AS TotalCash,
SUM(
IIf(TransactionType ='Credit',
TotalPrice, 0)
) AS TotalCredit,
SUM(
IIf(TransactionType ='Check',
TotalPrice, 0)
) AS TotalCheck,
SUM(
IIf(TransactionType ='Multiple',
IIf(MultiCash = 0,
0, MultiCash), 0)
) AS MultipleCash,
SUM(
IIf(TransactionType ='Multiple',
IIf(MultiCredit = 0,
0, MultiCredit), 0)
) AS MultipleCredit,
SUM(
IIf(TransactionType ='Multiple',
IIf(MultiCheck = 0,
0, MultiCheck), 0)
) AS MultipleCheck

FROM RECEIPT

WHERE ReceiptDate BETWEEN? AND ?

Error:

Generated SELECT statement.
Error in list of function arguments:'=' not recongized.
Unable to parse query text.

Edit:

Let me tell you what I want to do instead of just posting the code. This may be another easy way to solve this problem. So I want to start from vb. Extract the report from the report viewer in .net and tell me the bids used between specific dates.

Explosion-proof.

1/20/2013< br />Transaction Type Amount
Cash $100.00
Check $300.00
Credit $1,000.00
MultiCash $1,500.00
MultiCheck $1,500.00
MultiCredit $1,500.00

In There is something similar in the report viewer. The user will be able to select a specific date.
The Access database table used to extract information from it is shown below.

RECEIPT
-----------
ReceiptNumber (PK)
ReceiptDate
TotalPrice
TransactionType
MultiCash
MultiCheck
MultiCredit
TotalTax

Are there any other methods possible?

Thank you for your help.

terms such as:

IIf(MultiCash = 0, 0, MultiCash)

Do nothing. You say "If multicash is 0, use 0, otherwise use the value... "

It looks like an overly complicated way. Try this, it will give you data in a slightly different format, but I doubt it will be close to what you are after

< p>

SELECT TransactionType, 
SUM(TotalPrice) AS SumTotalPrice,
SUM(MultiCash) AS MultipleCash,
SUM(MultiCredit) AS MultipleCredit,
SUM (MultiCheck) AS MultipleCheck
FROM Receipt
WHERE ReceiptDate BETWEEN? AND ?
GROUP BY TransactionType

It also has the advantage that the query will naturally process the new Payment type.

I receive an error stating that the equal sign cannot be recognized. I always test my code in Access to make sure it works. Does anyone know Why is it so?

Code:

SELECT SUM(
IIf(TransactionType ='Cash',
TotalPrice, 0)< br />) AS TotalCash,
SUM(
IIf(TransactionType ='Credit',
TotalPrice, 0)
) AS TotalCredit,
SUM(
IIf(TransactionType ='Check',
TotalPrice, 0)
) AS TotalCheck,
SUM(
IIf(TransactionType ='Multiple',
IIf(MultiCash = 0,
0, MultiCash), 0)
) AS MultipleCash,
SUM(
IIf(TransactionType ='Multiple',
IIf(MultiCredit = 0,
0, MultiCredit), 0)
) AS MultipleCredit,
SUM(
IIf(TransactionType ='Multiple',
IIf(MultiCheck = 0,
0, MultiCheck), 0)
) AS MultipleCheck

FROM RECEIPT

WHERE ReceiptDate BETWEEN? AND ?

Error:

Generated SELECT statement.
Error in list of function arguments:'=' not recongized.
Unable to parse query text.

Edit:

Let me tell you what I want to do instead of just posting the code. This might be another easy way to solve this problem. So I want to start from vb. Extract the report from the report viewer in .net and tell me the bids used between specific dates.

Explosion-proof.

1/20/2013< br />Transaction Type Amount
Cash $100.00
Check $300.00
Credit $1,000.00
MultiCash $1,500.00
MultiCheck $1,500.00
MultiCredit $1,500.00

In There is something similar in the report viewer. The user will be able to select a specific date.
The Access database table used to extract information from it is shown below.

RECEIPT
-----------
ReceiptNumber (PK)
ReceiptDate
TotalPrice
TransactionTy pe
MultiCash
MultiCheck
MultiCredit
TotalTax

Is there any other method possible?

Thank you for your help.

Terms such as:

 IIf(MultiCash = 0, 0, MultiCash)

Do nothing. You say "If multicash is 0, use 0, otherwise use the value..."

It looks like Is an overly complicated way. Try this, it will give you data in a slightly different format, but I suspect it will be close to what you are after

SELECT TransactionType, 
SUM(TotalPrice) AS SumTotalPrice,
SUM(MultiCash) AS MultipleCash,
SUM(MultiCredit) AS MultipleCredit,
SUM(MultiCheck) AS MultipleCheck
FROM Receipt < br />WHERE ReceiptDate BETWEEN? AND ?
GROUP BY TransactionType

It also has the advantage of querying new payment types that will be naturally processed later.

< p>

Leave a Comment

Your email address will not be published.