Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Stored procedure with ORDER BY and results to DataTable

$
0
0

I Don't need the result as a bound data for what I'm needing to do here.

I have a datatable created by using a SQL stored procedure, and am using the code below to verify Product data. The stored procedure has an ORDER BY issueDate at the end of it. If I'm transfering the results to a DataTable with a DataTable.SELECT statement I'm not getting the sorted results that I thought would happen when the DataTable is created. I need the earliest date results and it's getting the first occurance of the product.

Product LotID  issueDate

901417 37140 2013-12-02
901418 37140 2013-12-02
901419 37140 2013-12-02

901417 37140 2013-12-01
901418 37140 2013-12-01
901419 37140 2013-12-01

// "yyyy-MM-dd"
string sortOrder = "issueDate";
DataRow[] Check = schemaTable.Select(string.Format("productID = '{0}' AND lotID = '{1}'", product, lotNum), sortOrder);

if (Check == null)
{
   .
   .
   .
   return null;
}
return (Check.Last<DataRow>());



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>