Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Display SQL query results in Windows Form

Display SQL query results in Windows Form

Scheduled Pinned Locked Moved C#
databasequestioncsharphelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hobbsieoz
    wrote on last edited by
    #1

    Hi im executing a sql command from my C# windows form. Its a count command : SELECT [COLUMN NAME], COUNT(*) FROM [DATABASE] GROUP BY [COLUMN]. 2 Columns load from the results, the column name, and the number of records (count). How can i display these results in a C# windows form? Datagrid, large textbox? Please help me on this.

    V A 2 Replies Last reply
    0
    • H hobbsieoz

      Hi im executing a sql command from my C# windows form. Its a count command : SELECT [COLUMN NAME], COUNT(*) FROM [DATABASE] GROUP BY [COLUMN]. 2 Columns load from the results, the column name, and the number of records (count). How can i display these results in a C# windows form? Datagrid, large textbox? Please help me on this.

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      hobbsieoz wrote:

      Datagrid

      Did you check out http://www.albahari.com/queryexpress.html[^]? This is a free open-source Windows Forms SQL Query Tool and it can help out a lot in Windows forms and SQL plays.

      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

      H 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        hobbsieoz wrote:

        Datagrid

        Did you check out http://www.albahari.com/queryexpress.html[^]? This is a free open-source Windows Forms SQL Query Tool and it can help out a lot in Windows forms and SQL plays.

        Vasudevan Deepak Kumar Personal Homepage Tech Gossips

        H Offline
        H Offline
        hobbsieoz
        wrote on last edited by
        #3

        This seems very long winded, is there another way.

        1 Reply Last reply
        0
        • H hobbsieoz

          Hi im executing a sql command from my C# windows form. Its a count command : SELECT [COLUMN NAME], COUNT(*) FROM [DATABASE] GROUP BY [COLUMN]. 2 Columns load from the results, the column name, and the number of records (count). How can i display these results in a C# windows form? Datagrid, large textbox? Please help me on this.

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          You can easily displyed it with in DataGrid. Just connect with database Create DataAdapter (SqlDataAdapter da=new SqlDataAdapter(Command,Connection)) Create a Dataset (e.g Dataset Ds=new DataSet()) Fill DataSet With DataAdpter (e.g Da.Fill(ds)) And DataGrid1.DataSource=Ds Hope This will help :cool:

          Happy Programming ----------------- Abhijit Jana Noida, India

          H 1 Reply Last reply
          0
          • A Abhijit Jana

            You can easily displyed it with in DataGrid. Just connect with database Create DataAdapter (SqlDataAdapter da=new SqlDataAdapter(Command,Connection)) Create a Dataset (e.g Dataset Ds=new DataSet()) Fill DataSet With DataAdpter (e.g Da.Fill(ds)) And DataGrid1.DataSource=Ds Hope This will help :cool:

            Happy Programming ----------------- Abhijit Jana Noida, India

            H Offline
            H Offline
            hobbsieoz
            wrote on last edited by
            #5

            I have tried this method, but did not display my count number results

            A J 2 Replies Last reply
            0
            • H hobbsieoz

              I have tried this method, but did not display my count number results

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              why not ?:doh: What error r u getting :confused:

              Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

              1 Reply Last reply
              0
              • H hobbsieoz

                I have tried this method, but did not display my count number results

                J Offline
                J Offline
                J4amieC
                wrote on last edited by
                #7

                You may need to Alias the count column to make it easier to identify in the resulting dataset... something like SELECT foo, **COUNT(*) AS countOfFoos** FROM fooTable GROUP BY foo

                --- How to get answers to your questions[^]

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups