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. Learning Datasets...

Learning Datasets...

Scheduled Pinned Locked Moved C#
visual-studiodata-structurestutorialquestionlearning
8 Posts 6 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.
  • J Offline
    J Offline
    JollyMansArt
    wrote on last edited by
    #1

    If someone has a better idea in how I can do this please let me know. Normally I what I would do is call sqlreader and each field I would put into a custom array to use through out the application. Well now that I have learned how to create a dataset, while in code without using the vs customized dataset's interface...

    string connectionString = TheSQLConnectionString.ConnectionString.ToString();
    //DataSet dtSet = new DataSet();
    //SqlConnection connection;
    using (connection = CreateConn())
    {
    command = new SqlCommand(TheSQLCommand, connection);
    SqlDataAdapter adapter = new SqlDataAdapter(command);
    adapter.Fill(dtSet);
    }

    Now what I want to be able to do is take the (dtSet) dataset and in code read each row and each row's columns of data. However I want to place this code in a class Passing the parameters (table, row, and column) and I want the class procedure to return the value. Can someone point me in the right direction please in how to understand datasets in order to accomplish this? Thanks in advance.

    P 1 Reply Last reply
    0
    • J JollyMansArt

      If someone has a better idea in how I can do this please let me know. Normally I what I would do is call sqlreader and each field I would put into a custom array to use through out the application. Well now that I have learned how to create a dataset, while in code without using the vs customized dataset's interface...

      string connectionString = TheSQLConnectionString.ConnectionString.ToString();
      //DataSet dtSet = new DataSet();
      //SqlConnection connection;
      using (connection = CreateConn())
      {
      command = new SqlCommand(TheSQLCommand, connection);
      SqlDataAdapter adapter = new SqlDataAdapter(command);
      adapter.Fill(dtSet);
      }

      Now what I want to be able to do is take the (dtSet) dataset and in code read each row and each row's columns of data. However I want to place this code in a class Passing the parameters (table, row, and column) and I want the class procedure to return the value. Can someone point me in the right direction please in how to understand datasets in order to accomplish this? Thanks in advance.

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      If you don't actually want the DataSet, then don't create the DataSet. I prefer to just use a DataReader and directly populate the classes I intend to use. DataAdapters, DataSets, and DataGrid(View)s weren't created for actual real-world use -- their only purpose is allow MS demonstrators to quickly create barely-useful applications to make easily-impressed audiences go "ooohhh".

      D K M 3 Replies Last reply
      0
      • P PIEBALDconsult

        If you don't actually want the DataSet, then don't create the DataSet. I prefer to just use a DataReader and directly populate the classes I intend to use. DataAdapters, DataSets, and DataGrid(View)s weren't created for actual real-world use -- their only purpose is allow MS demonstrators to quickly create barely-useful applications to make easily-impressed audiences go "ooohhh".

        D Offline
        D Offline
        Dan Mos
        wrote on last edited by
        #3

        PIEBALDconsult wrote:

        DataAdapters, DataSets, and DataGrid(View)s weren't created for actual real-world use -- their only purpose is allow MS demonstrators to quickly create barely-useful applications to make easily-impressed audiences go "ooohhh".

        :thumbsup: 10+

        I bug

        J 1 Reply Last reply
        0
        • P PIEBALDconsult

          If you don't actually want the DataSet, then don't create the DataSet. I prefer to just use a DataReader and directly populate the classes I intend to use. DataAdapters, DataSets, and DataGrid(View)s weren't created for actual real-world use -- their only purpose is allow MS demonstrators to quickly create barely-useful applications to make easily-impressed audiences go "ooohhh".

          K Offline
          K Offline
          Keith Barrow
          wrote on last edited by
          #4

          Motion Seconded, on all points.

          ragnaroknrol The Internet is For Porn[^]
          Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

          1 Reply Last reply
          0
          • P PIEBALDconsult

            If you don't actually want the DataSet, then don't create the DataSet. I prefer to just use a DataReader and directly populate the classes I intend to use. DataAdapters, DataSets, and DataGrid(View)s weren't created for actual real-world use -- their only purpose is allow MS demonstrators to quickly create barely-useful applications to make easily-impressed audiences go "ooohhh".

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Cynical, definately cynical.

            Never underestimate the power of human stupidity RAH

            P 1 Reply Last reply
            0
            • D Dan Mos

              PIEBALDconsult wrote:

              DataAdapters, DataSets, and DataGrid(View)s weren't created for actual real-world use -- their only purpose is allow MS demonstrators to quickly create barely-useful applications to make easily-impressed audiences go "ooohhh".

              :thumbsup: 10+

              I bug

              J Offline
              J Offline
              JollyMansArt
              wrote on last edited by
              #6

              Ok how do you recommend getting the data from sql server database into the application if you do not recommend the use of datasets?

              L 1 Reply Last reply
              0
              • J JollyMansArt

                Ok how do you recommend getting the data from sql server database into the application if you do not recommend the use of datasets?

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                that question has been answered here already. :|

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                1 Reply Last reply
                0
                • M Mycroft Holmes

                  Cynical, definately cynical.

                  Never underestimate the power of human stupidity RAH

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  And experienced as well.

                  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