Get Data from Calulated DataSet
i have following dataset run following query,
select min(start_date) mindate, max(exp_date) maxdate
from sales
where (memberid = @memberid)
called, getdatabyminmaxdates
when run following code;
memdata.ezrangedatatable ezdata = memdatatableadapters.ezrangetableadapter ezconnect = new memdatatableadapters.ezrangetableadapter(); memdata.ezrangedatatable sales2data; memdata.ezrangerow sales2row; sales2data= ezconnect.getdatabyminmaxdates(memberid); if (ezdata.count > 0) { sales2row = (memdata.ezrangerow)sales2data.rows[0]; datetime m_min= sales2row.mindate; datetime m_max= sales2row.maxdate; }receive error sales2row.mindate , sales2row.maxdate doesn't exist. how ght mindate , maxdate out of dataset?
it's obvious using typed datasets , ezrangedatatable , ezrangerow "classes" in typed dataset.
is compiler error or runtime error?
if it's runtime error, exact error message?
if it's compiler error, means don't have mindate , maxdate defined in dataset's xsd definition. need add 2 datetime columns xsd in definition of the ezrange datatable. or, if don't want add columns reason, you'd need reference them differently, , convert value ... like this:
datetime m_min; datetime m_max datetime.tryparse(sales2row["mindate"], out m_min); datetime.tryparse(sales2row["maxdate"], out m_max);
~~bonnie dewitt [c# mvp]
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment