I have an SQL statement in my C# program that looks like:
SELECT * FROM XXX.dbo.XXX
WHERE Source = 'OH'
AND partnum = '1231202085'
ORDER BY partnum, Packaging, Quantity
When running this query in SQL Server Management, the results are ordered as expected.
My first 3 results have the same partnum and Packaging with Quantities of 32.0, 50.8, and 51.0.
However, when I run the query from my program, the result set with quantity 50.8 is the first to be returned. The datatype of Quantity is decimal(18,9). I’ve tried cast, it doesn’t appear to be a datatype problem.
I cant figure out why its getting the middle quantity.
Thank you guys for the quick responses however after a little more testing I found my issue in my C# code, not the sql.
After getting the query results I hade:
if (PurchOrder.Read())
while (PurchOrder.Read())
Overlooking the fact that the first read would in fact read my first result, then the while whould get my second result.
Ive replace the if statement with:
if (PurchOrder.HasRows == true)
and everything looks to fine.
Again, thank you for the responses though. Sorry for the mislead question.
-Cody
Thank you guys for the quick responses however after a little more testing I found my issue in my C# code, not the sql.
After getting the query results I hade:
if (PurchOrder.Read())
while (PurchOrder.Read())
Overlooking the fact that the first read would in fact read my first result, then the while whould get my second result.
Ive replace the if statement with:
if (PurchOrder.HasRows == true)
and everything looks to fine.
Again, thank you for the responses though. Sorry for the mislead question.
-Cody