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. Database & SysAdmin
  3. Database
  4. DataTable

DataTable

Scheduled Pinned Locked Moved Database
databasequestion
3 Posts 3 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.
  • G Offline
    G Offline
    Guinness4Strength
    wrote on last edited by
    #1

    Whats the best way to get an empty Typed DataTable ? I've been using an SQL statement that returns zero rows, but the overhead of such a statement is going to get too big once the SQL table gets large.

    D 1 Reply Last reply
    0
    • G Guinness4Strength

      Whats the best way to get an empty Typed DataTable ? I've been using an SQL statement that returns zero rows, but the overhead of such a statement is going to get too big once the SQL table gets large.

      D Offline
      D Offline
      Dr_X
      wrote on last edited by
      #2

      Using the SQL statement is proably the easiest way. There shouldn't be much overhead regardless of the SQL statement if no rows are returned and the WHERE clause is set if an Key column not have a value in the table. SELECT * FROM Employees WHERE EmployeeID = 0 Regardless of how many table are in the SQL statement, just make sure they are all joined correctly. After you obtain the DataTable the 1st and only time, just cache it or use a singleton. Michael

      R 1 Reply Last reply
      0
      • D Dr_X

        Using the SQL statement is proably the easiest way. There shouldn't be much overhead regardless of the SQL statement if no rows are returned and the WHERE clause is set if an Key column not have a value in the table. SELECT * FROM Employees WHERE EmployeeID = 0 Regardless of how many table are in the SQL statement, just make sure they are all joined correctly. After you obtain the DataTable the 1st and only time, just cache it or use a singleton. Michael

        R Offline
        R Offline
        Rein Hillmann
        wrote on last edited by
        #3

        Here's a statement that uses less overhead since it won't require any kind of table-scan or index lookup: SELECT * FROM Employees WHERE 1=2

        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