c# - Collecting data in same query -


i need fetch data according date single query. , display data in c#

i have tried following query fetch record

" select distinct date,news news order date "

result of query:

  date           news  2/3/2014        jeo news 2/4/2014        aaj news 2/4/2014        aag 2/4/2014        express news 2/5/2014        dunya news 

the problem : how can display record in c# according format?

2/3/2014 jeo news  2/4/2014 aaj news aag express news  2/5/2014 dunya news 

here c# code

 try         {             da.fill(dt);             for(int i=0; i<dt.rows.count; i++)             {             console.writeline(dt.rows[i]["date"].tostring());              console.writeline(dt.rows[i]["news"].tostring()) ;              console.write("\n");             }             console.read();         }         catch (sqlexception ex)         {             console.writeline(ex);         } 

just throw out there, ordering date, take route of comparing last date current one:

var olddate = datetime.minvalue; (int = 0; < dt.rows.count; i++) {     var newdate = datetime.parse(dt.rows[i]["date"].tostring());     if (newdate != olddate)     {          console.writeline();          console.writeline(newdate.toshortdatestring());     }     console.writeline(dt.rows[i]["news"].tostring());      olddate = newdate;  }  console.read(); 

this'll produce desired output


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -