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. query dataset

query dataset

Scheduled Pinned Locked Moved C#
databasequestion
7 Posts 5 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.
  • X Offline
    X Offline
    xrado
    wrote on last edited by
    #1

    how do i query dataset with sql statement

    M P 2 Replies Last reply
    0
    • X xrado

      how do i query dataset with sql statement

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbcondatasets.asp[^] Read the section on Populating Datasets and follow the links on data adapters. Marc My website
      Latest Articles: Object Comparer String Helpers

      1 Reply Last reply
      0
      • X xrado

        how do i query dataset with sql statement

        P Offline
        P Offline
        Paul Brower
        wrote on last edited by
        #3

        If you've already got a populated dataset, you could do the following: Let's say you got a DataSet (ds) with a 'Customer' Table, and you want all the customers that have a first name of 'Paul' DataView dv = new DataView(ds.Tables["Customer"]) ; dv.RowFilter = "FirstName = 'Paul'" ; Now, you have records that have 'Paul' in the FirstName field, in your DataView. Is that what you meant?

        X 1 Reply Last reply
        0
        • P Paul Brower

          If you've already got a populated dataset, you could do the following: Let's say you got a DataSet (ds) with a 'Customer' Table, and you want all the customers that have a first name of 'Paul' DataView dv = new DataView(ds.Tables["Customer"]) ; dv.RowFilter = "FirstName = 'Paul'" ; Now, you have records that have 'Paul' in the FirstName field, in your DataView. Is that what you meant?

          X Offline
          X Offline
          xrado
          wrote on last edited by
          #4

          hmm..maybe yes i have dataset already populated but is there a way to execute a sql command on dataset data

          P D 2 Replies Last reply
          0
          • X xrado

            hmm..maybe yes i have dataset already populated but is there a way to execute a sql command on dataset data

            P Offline
            P Offline
            Paul Brower
            wrote on last edited by
            #5

            Yes. ** To execute a stored procedure, that gets the value of an output parameter //you need to have a SqlConnection object SqlCommand something = new SqlCommand("StoredProcName",[sqlConnection]) ; something.CommandType = CommandType.StoredProcedure ; //for each paramter in the stored proc, do the following something.Parameters.Add(@Parm1, SqlDbType.Int) ; something.Parameters["@Parm1"].Direction = ParameterDirection.InputOutput ; something.Parameters["@Parm1"].Value = [in this case an integer value] ; something.ExecuteNonQuery() ; Int32 somevalue = Convert.ToInt32(something.Parameters["@Parm1"].Value) ; ** there are many ways to deal with executing Sql Commands. You can set up a SqlCommand for dataadapters for automatically updating your dataset, you can also use SqlCommand to just execute a sql statement. Look in your MSDN help for more info on this, or search CodeProject articles ... there are lots of them on this issue.

            1 Reply Last reply
            0
            • X xrado

              hmm..maybe yes i have dataset already populated but is there a way to execute a sql command on dataset data

              D Offline
              D Offline
              david cohoon
              wrote on last edited by
              #6

              You can use the Select() of a datatable... // create and populate a dataset DataSet ds = new DataSet(); DataTable table = ds.Tables.Add(); table.Columns.Add("Name", System.String); table.Columns.Add("Value", System.String); table.Rows.Add(new string[] {"David", "one"}); table.Rows.Add(new string[] {"George", "two"}); // call DataTable.Select() to get all rows with name starting with 'D' DataRow[] resultRows = table.Select("Name Like 'D%'"); Hope it helps! -Cursor

              A 1 Reply Last reply
              0
              • D david cohoon

                You can use the Select() of a datatable... // create and populate a dataset DataSet ds = new DataSet(); DataTable table = ds.Tables.Add(); table.Columns.Add("Name", System.String); table.Columns.Add("Value", System.String); table.Rows.Add(new string[] {"David", "one"}); table.Rows.Add(new string[] {"George", "two"}); // call DataTable.Select() to get all rows with name starting with 'D' DataRow[] resultRows = table.Select("Name Like 'D%'"); Hope it helps! -Cursor

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                it helps! thx!:)

                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