I have written a SQL query to find product information in a c# program and it doesn't seem to work at all! I have tested a variety of other queries with my C# code and it works fine, but this throws an exception every time.
SELECT TOP (1) CONVERT(varchar, tmpRptAssetEvent.EventTimeStamp, 120) AS 'DateTime', ResultEnum.ResultEnumName AS 'Result',
AssetItems.AssetSN AS 'SerialNumber', Events.EventAddDate as 'EntryAddDateTime', Events.ExecTime as 'TestTime',
ModelEnum.PartName as 'Model', EventEnum.Name AS 'EventName', ProcessEnum.Name AS 'ProcessName'
AssetItems ON tmpRptAssetEvent.AssetID = AssetItems.AssetID INNER JOIN
ResultEnum ON tmpRptAssetEvent.EventResult = ResultEnum.ResultEnumID INNER JOIN
Station ON tmpRptAssetEvent.StationID = Station.StationID INNER JOIN
ModelEnum ON tmpRptAssetEvent.ModelEnum = ModelEnum.ModelEnumID INNER JOIN
EventEnum ON tmpRptAssetEvent.EventEnumID = EventEnum.EventEnumID INNER JOIN
ProcessEnum ON tmpRptAssetEvent.ProcessEnumID = ProcessEnum.ProcessEnumID INNER JOIN
Events ON tmpRptAssetEvent.EventID = Events.EventID
WHERE (Station.StationName = '" + station + "')
ORDER BY tmpRptAssetEvent.EventTimeStamp desc;