how to empty a dataset/dataadapter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aussie Rules

    how to empty a dataset/dataadapter

    Hi,

    I populate a dataset and then bind a grid to the dataset. The application
    allows the user
    to repopulate the dataset to show different data in the application.

    The problem seems to be that the dataset, keeps the old dataset, as the grid
    then displayes multiple datasets, even though I am using the new keyword

    Is there a way to totally destroy the contents of the dataset each time I
    repopulate it?

    My code is :


    Dim command2 As New OleDbCommand("s elect * from WorkSheet_CostD etail
    where sheet=" & intWorkSheet, dbConnection)

    Dim ds As New DataSet
    Dim da2 As New OleDbDataAdapte r(command2)

    da2.Fill(ds, "ProjectCos ts")

    FpSpread1.DataS ource = ds


  • Cor Ligthert[MVP]

    #2
    Re: how to empty a dataset/dataadapter

    Aussie

    As you create a new dataset, you have to set it again as datasource to the
    control.
    The old dataset stays as long as there is a reference to it from that
    DataGrid.

    If you don't use the new dataset, then you can clear the dataset. Simple
    enough YourDataset.Cle ar

    Cor

    "Aussie Rules" <aussie@nospam. comschreef in bericht
    news:%235lMEWYh IHA.1408@TK2MSF TNGP03.phx.gbl. ..
    Hi,
    >
    I populate a dataset and then bind a grid to the dataset. The application
    allows the user
    to repopulate the dataset to show different data in the application.
    >
    The problem seems to be that the dataset, keeps the old dataset, as the
    grid then displayes multiple datasets, even though I am using the new
    keyword
    >
    Is there a way to totally destroy the contents of the dataset each time I
    repopulate it?
    >
    My code is :
    >
    >
    Dim command2 As New OleDbCommand("s elect * from
    WorkSheet_CostD etail where sheet=" & intWorkSheet, dbConnection)
    >
    Dim ds As New DataSet
    Dim da2 As New OleDbDataAdapte r(command2)
    >
    da2.Fill(ds, "ProjectCos ts")
    >
    FpSpread1.DataS ource = ds
    >
    >

    Comment

    Working...