how to present sql query in data grid view c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eranby
    New Member
    • Aug 2007
    • 17

    how to present sql query in data grid view c#

    hi,

    I'm using access db in my c# program I have a select query and I want to present
    the result in data grid view ,I succeed doing that with this while loop
    [CODE=c]int i = 0,j=0;
    while (dbReader.Read( ))
    {
    dataGridView2.R ows.Add();
    dataGridView2[j, dataGridView2.R ows.Count - 1].Value = (string) [ dbReader.GetVal ue(0).ToString( ); j++;
    dataGridView2[j, dataGridView2.R ows.Count - 1].Value = (string)dbReade r.GetValue(1); j++;
    dataGridView2[j, dataGridView2.R ows.Count - 1].Value = (string)dbReade r.GetValue(2);
    i++;
    j = 0;
    }[/CODE]
    is there an appropriate way doing it that sent the all result to the table at once?
    thanks,
    Last edited by NeoPa; Mar 21 '08, 12:01 AM. Reason: Please use [CODE] tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    You've asked this question in the Access forum, which is understandable, but as the question seems to be about how to write your c# code I've moved it into the forum that deals with that.

    If there are Access questions that arise from this then I still have the thread linked and will keep an eye on how it develops.

    Comment

    Working...