How to return multiple at the same time using DataGridView for C#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MengChee
    New Member
    • Aug 2010
    • 4

    #1

    How to return multiple at the same time using DataGridView for C#.net

    i just the beginner.My db is using MS SQL server 2008
  • benwizzle
    New Member
    • May 2010
    • 72

    #2
    I'm not quite sure what your asking. Please elaborate.

    Comment

    • MrMancunian
      Recognized Expert Contributor
      • Jul 2008
      • 569

      #3
      1. Write query
      2. Execute query
      3. Save data in DataTable
      4. Bind DataTable to Gridview

      Have fun figuring it out!

      Steven

      Comment

      • benwizzle
        New Member
        • May 2010
        • 72

        #4
        If your referring to what Mr.Mancunian just said...i can help you out there.

        Comment

        • MengChee
          New Member
          • Aug 2010
          • 4

          #5
          i doing a website that need to handle the search result. becoz normal the label just can handle one result. so the datagridview can solve this problem but how to implement it?

          Comment

          • MrMancunian
            Recognized Expert Contributor
            • Jul 2008
            • 569

            #6
            See my first post:

            1. Write query
            2. Execute query
            3. Save data in DataTable
            4. Bind DataTable to Gridview

            Steven

            Comment

            • benwizzle
              New Member
              • May 2010
              • 72

              #7
              General this is how i do query's in asp.net.
              First you must make sure you load the assembly to your page.
              Code:
              using System.Data.SqlClient;
              Then declare a connection, command, datatable, and a dataadapter.
              Code:
              SqlConnection con = new SqlConnection("connectionstring");
              SqlCommand cmd = new SqlCommand("put command here", con);
              DataTable dt = new DataTable();
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              
              da.Fill(dt);
              GridView.DataSource = dt;
              GridView.DataBind();
              Hope this helps

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Please review the following article that outline how to use a database:
                Database tutorial Part 1
                Database tutorial Part 2

                Comment

                Working...