How to update dbf file with powershell?

Welcome Forums General PowerShell Q&A How to update dbf file with powershell?

Viewing 3 reply threads
  • Author
    Posts
    • #275877
      Participant
      Topics: 1
      Replies: 2
      Points: 20
      Rank: Member

      Hi At first I apologize for my English.

      I am asking for help in solving my problem.

      I have a simple script that reads data from the users.dbf file (via Microsoft.ACE.OLEDB.12.0).

      For the user X it has to fill in the id_sys field

      How do I update the users.dbf file?

      =====================================

      $conn = new-object System.Data.OleDb.OleDbConnection(“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\CZM_users;Extended Properties=dBase IV”)
      $conn.open()

      $cmd = new-object System.Data.OleDb.OleDbCommand(“select * from users”, $Conn)
      $da = new-object System.Data.OleDb.OleDbDataAdapter($cmd)
      $dt = new-object System.Data.dataTable
      $da.fill($dt)

      #$dt | select nazwisko,id_sys #etc

      foreach ($i in $dt)
      {
      if ($i.nazwisko -eq “Majewska Beata”)
      {
      $i.ID_SYS = “MB”
      }
      }

      ??? # How to update the users.dbf file

      $conn.Close()

      ========================================

       

      Thx Adam

    • #275994
      Participant
      Topics: 17
      Replies: 1951
      Points: 3,988
      Helping Hand
      Rank: Community Hero

      Take a look at this:

      http://powershell-tips.blogspot.com/2012/07/reading-updating-and-inserting-data.html

      Not sure if the query is working for you, but the “Data Source” should reference the file and it’s just a path in your posted code.

    • #276384
      Participant
      Topics: 1
      Replies: 2
      Points: 20
      Rank: Member

      Thank you,

      I will try tomorrow and write about my results.

      thx

    • #276540
      Participant
      Topics: 1
      Replies: 2
      Points: 20
      Rank: Member

      Hi

      Thank you @Rob Simmers

      Your tip was very good.

      Good job

      My working script

       

      Thx

      Adam

Viewing 3 reply threads
  • You must be logged in to reply to this topic.