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. Visual Basic
  4. DataSets vs Queries

DataSets vs Queries

Scheduled Pinned Locked Moved Visual Basic
databasequestionvisual-studio
2 Posts 2 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.
  • M Offline
    M Offline
    medicenpringles
    wrote on last edited by
    #1

    I have a couple of different procedures that retrieve data from a single database. Both return a single value, either an Integer or DateTime. But the one that returns an integer accesses the data by connecting to the database and returning the data using .ExecuteScalar, while the other one builds a DataAdapter, a DataSet, and a DataTable, then references the DataTable to get the data. my question is, is there any advantge to using DataSets over directly query-ing the database?

    M 1 Reply Last reply
    0
    • M medicenpringles

      I have a couple of different procedures that retrieve data from a single database. Both return a single value, either an Integer or DateTime. But the one that returns an integer accesses the data by connecting to the database and returning the data using .ExecuteScalar, while the other one builds a DataAdapter, a DataSet, and a DataTable, then references the DataTable to get the data. my question is, is there any advantge to using DataSets over directly query-ing the database?

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      The difference here is not the dataset or not, it is the data adapter or the execute scalar method. Executescalar returns a single value and will always return a single value. The other query, if it always returns a single value would possibly benefit from using the executescalar method b/c it wont use all that memory overhead with datasets and adapters and such. If you will need to return more than a single value then you have 2 choices really, the dataadapter allows you grab a dataset or fill a datatable - or you can use a datareader. Both return a set of data and have their benefits and problems. So after a long windy explaination - you are querying the database no matter what, but one uses more objects to get the data. Cleako

      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