Duplicate rows in the Dataset!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • helloitsme
    New Member
    • Oct 2006
    • 20

    Duplicate rows in the Dataset!

    Hello!

    I use DataAdapter.Fil l method to fill the dataset with data from a SQL database table. But when the same method is called for a second time subsequently, it appends the data instead of overwriting the duplicate rows in the table.

    For example, i use DataAdapter.Fil l(mydataset,"my table"). the "mytable" has 50 rows and copies the same to "maytable" in mydataset. But after a subsequent call to DataAdapter.Fil l(mydataset,"my table"), the mytable in mydataset has 100 rows (i.e all the 50 rows duplicated).

    Can anyone please tell me how to avoid that!!
    I hope I have posted this in the right forum,else let me know...

    Thank you!
  • jorgepino
    New Member
    • Oct 2006
    • 6

    #2
    the DataAdapter does not set a PrimaryKey value for the resulting DataTable. You must explicitly define the primary key to ensure that duplicate rows are resolved correctly

    Comment

    • helloitsme
      New Member
      • Oct 2006
      • 20

      #3
      Thank you for replying...

      I tried doing so using the following before doing the .Fill -


      Code:
      DA.MissingSchemaAction = MissingSchemaAction.AddWithKey;
      if this is what you were talking about, then this did not help either...
      Please let me know if did something wrong or understood wrong...

      thanx...

      Comment

      Working...