Skip to main content
2 of 3
deleted 31 characters in body; edited tags
Daniel Hutmacher
  • 9.1k
  • 1
  • 26
  • 52

VB.Net gives Error with CASE SELECT

The following VB.Net code runs fine on SQL Server but gives an error on Access:

sql = "SELECT sr.itemcode, sr.itemname,  SUM(CASE WHEN sr.transdate='4/14/2016' THEN sr.temunits] END) AS [Units Sold], " & _
                    "SUM(sr.itemunits) AS [Total Units Sold] " & _
                  "FROM [tblINV_SalesRecord] AS sr WHERE sr.transdate <= '4/14/2016' GROUP BY sr.itemcode, sr.itemname"

The error is:

IErrorInfo.GetDescription Failed with E_FAIL(0x80004005), -System.Data