IErrorInfo.GetDescription failed with E_FAIL(0x80004005) on SQL Query

0

This is my Query

SELECT TOP 1 MAX(CAST(Id AS int)) , Ddate, Name FROM WonPrize WHERE Ddate=@Ddate GROUP BY Id,Ddate,Name

The Query is giving me an error code on VB.NET.

IErrorInfo.GetDescription failed with E_FAIL(0x80004005)

I don't think I have an error with the syntax that I am composing

I am trying to display the MAX ID but MAX(Id) is not displaying the Number 2 Id so I tried to use this MAX(CAST(Id AS int)). and it gives me an error code. What should be my mistakes?

I am using the oledb.

vb.net
asked on Stack Overflow Aug 2, 2018 by Noypipyon

1 Answer

0

Due to oledb bug on VB.NET I just change the syntax.

From:

SELECT TOP 1 MAX(CAST(Id AS int)) , Ddate, Name FROM WonPrize WHERE Ddate=@Ddate GROUP BY Id,Ddate,Name

To:

SELECT TOP 1 Id, Ddate, Name FROM WonPrize WHERE Ddate=@Ddate AND Id=(SELECT MAX(Id) FROM WonPrize)

And This resolves my Problem.

oledb is not working together with 2nd and 3rd column value using MAX(value) and MIN(value) I decided to put it on WHERE statement since the MAX and MIN will only work on oledb on a single value. And I think that the First syntax is only working on SQLClient and not on OLEDB.

answered on Stack Overflow Aug 2, 2018 by Noypipyon

User contributions licensed under CC BY-SA 3.0