Dataset Object updating

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

    #1

    Dataset Object updating

    Is there a way to update a DataSet Object?

    I have a Dataset Object (DataSetObj.Tab les(0) - one table) that I read in
    from a .csv file.

    I normally do the following to get my data from the .csv:

    Dim DataSetObj As New DataSet
    Dim DTDepartment As New DataTable
    Dim dt As New DataTable

    Dim da As New OleDb.OleDbData Adapter("Select * from " & "temp.csv", conn)
    da.Fill(DataSet Obj)

    I can get some rows by doing the following:

    drCollection = DataSetObj.Tabl es(1).Select("F 1 = 'FRANK'")

    Is there a way to Update the tables inside the Dataset?

    For example: I would like to change the all the values in Column 1 to 1084
    if Column 4 = 'Retirement' and change all the values to 5300 if Column 4 =
    'Medicare Employer' etc.

    I would then read the file and output it to another .csv file.

    Thanks,

    Tom


  • Jonathan Boivin

    #2
    Re: Dataset Object updating

    Hi there,

    I never tried out with a CVS file, but with a database it works fine.

    The only thing you have to do is retreiving the data you need to change
    using the Select method. Then you modify the column you need by using
    ds.Tables("TABL ENAME").Rows(RO WINDEX)("COLUMN NAME") = YOURVALUE in a For
    loop. And finally, you use your DataAdapter Update method to save to the CVS
    file.

    Hoping this works,
    Jonathan Boivin
    ---
    jonathanboivin@ cints.net | http://www.cints.net
    "tshad" <t@home.coma écrit dans le message de news:
    eeLcK9KcHHA.426 0@TK2MSFTNGP02. phx.gbl...
    Is there a way to update a DataSet Object?
    >
    I have a Dataset Object (DataSetObj.Tab les(0) - one table) that I read in
    from a .csv file.
    >
    I normally do the following to get my data from the .csv:
    >
    Dim DataSetObj As New DataSet
    Dim DTDepartment As New DataTable
    Dim dt As New DataTable
    >
    Dim da As New OleDb.OleDbData Adapter("Select * from " & "temp.csv", conn)
    da.Fill(DataSet Obj)
    >
    I can get some rows by doing the following:
    >
    drCollection = DataSetObj.Tabl es(1).Select("F 1 = 'FRANK'")
    >
    Is there a way to Update the tables inside the Dataset?
    >
    For example: I would like to change the all the values in Column 1 to 1084
    if Column 4 = 'Retirement' and change all the values to 5300 if Column 4 =
    'Medicare Employer' etc.
    >
    I would then read the file and output it to another .csv file.
    >
    Thanks,
    >
    Tom
    >
    >

    Comment

    • tshad

      #3
      Re: Dataset Object updating

      "Jonathan Boivin" <djon@cyberinte rnautes.netwrot e in message
      news:uzopbjLcHH A.984@TK2MSFTNG P04.phx.gbl...
      Hi there,
      >
      I never tried out with a CVS file, but with a database it works fine.
      >
      The only thing you have to do is retreiving the data you need to change
      using the Select method. Then you modify the column you need by using
      ds.Tables("TABL ENAME").Rows(RO WINDEX)("COLUMN NAME") = YOURVALUE in a For
      loop. And finally, you use your DataAdapter Update method to save to the
      CVS file.
      I was hoping to do a bunch of updates as I would with sql. The loops would
      do what I need to do. I would need to do a loop for each change or one loop
      with a lot of if statements. I was hoping to do the update to stop that.
      But the for loop will work.

      How would I do the DataAdapter Update method to update the .cvs file using
      the statements below?

      Thanks,

      Tom

      In the DataAdapter can you do
      >
      Hoping this works,
      Jonathan Boivin
      ---
      jonathanboivin@ cints.net | http://www.cints.net
      "tshad" <t@home.coma écrit dans le message de news:
      eeLcK9KcHHA.426 0@TK2MSFTNGP02. phx.gbl...
      >Is there a way to update a DataSet Object?
      >>
      >I have a Dataset Object (DataSetObj.Tab les(0) - one table) that I read in
      >from a .csv file.
      >>
      >I normally do the following to get my data from the .csv:
      >>
      >Dim DataSetObj As New DataSet
      >Dim DTDepartment As New DataTable
      >Dim dt As New DataTable
      >>
      >Dim da As New OleDb.OleDbData Adapter("Select * from " & "temp.csv", conn)
      >da.Fill(DataSe tObj)
      >>
      >I can get some rows by doing the following:
      >>
      >drCollection = DataSetObj.Tabl es(1).Select("F 1 = 'FRANK'")
      >>
      >Is there a way to Update the tables inside the Dataset?
      >>
      >For example: I would like to change the all the values in Column 1 to
      >1084 if Column 4 = 'Retirement' and change all the values to 5300 if
      >Column 4 = 'Medicare Employer' etc.
      >>
      >I would then read the file and output it to another .csv file.
      >>
      >Thanks,
      >>
      >Tom
      >>
      >>
      >
      >

      Comment

      Working...