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. DataSet.Clear problem

DataSet.Clear problem

Scheduled Pinned Locked Moved C#
helptutorialquestion
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.
  • H Offline
    H Offline
    hdv212
    wrote on last edited by
    #1

    hi i have a method that return DataTable (named GetData), now i want to load returned DataTable object to DataSet by this code :

    this.ds.Load(dal.GetData(cmd1).CreateDataReader(), LoadOption.OverwriteChanges, new string[] { "transaction1" });

    but before, load data, i want to clear some tables of my dataset objects by this code :

    this.ds.Tables[0].Clear(); // error in this line

    but at runTime the following error has shown me :

    Cannot find table 0

    how to solve my problem and how to clear before fill ? thanks

    G N 2 Replies Last reply
    0
    • H hdv212

      hi i have a method that return DataTable (named GetData), now i want to load returned DataTable object to DataSet by this code :

      this.ds.Load(dal.GetData(cmd1).CreateDataReader(), LoadOption.OverwriteChanges, new string[] { "transaction1" });

      but before, load data, i want to clear some tables of my dataset objects by this code :

      this.ds.Tables[0].Clear(); // error in this line

      but at runTime the following error has shown me :

      Cannot find table 0

      how to solve my problem and how to clear before fill ? thanks

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      hdv212,

      if (this.ds.Tables.Count != 0)
      {
      this.ds.Tables[0].Clear();
      }

      Regards, Gareth. (FKA gareth111)

      1 Reply Last reply
      0
      • H hdv212

        hi i have a method that return DataTable (named GetData), now i want to load returned DataTable object to DataSet by this code :

        this.ds.Load(dal.GetData(cmd1).CreateDataReader(), LoadOption.OverwriteChanges, new string[] { "transaction1" });

        but before, load data, i want to clear some tables of my dataset objects by this code :

        this.ds.Tables[0].Clear(); // error in this line

        but at runTime the following error has shown me :

        Cannot find table 0

        how to solve my problem and how to clear before fill ? thanks

        N Offline
        N Offline
        NK7
        wrote on last edited by
        #3

        First check your dataset have any table. If not no need to clear.

        kesavan

        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