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. Database & SysAdmin
  3. Database
  4. Updating a FoxPro dbf file using VB.net

Updating a FoxPro dbf file using VB.net

Scheduled Pinned Locked Moved Database
csharpwindows-adminsaleshelp
4 Posts 2 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.
  • J Offline
    J Offline
    jkirkerx
    wrote on last edited by
    #1

    This is the first I'm trying to update a row in a FoxPro DBF file. My code runs without error, but the row just won't update. I get a 0 back from ExecuteNonQuery I tried hard coding the customer number but same thing. Tried just updating 1 column FCOMPANY, same thing. I must be missing something here, like perhaps a cursor or something. The SELECT line was a feeble attempt to try something.

    Dim m_path As String = Nothing
    Dim dwXCode As Integer = registry_shared.read_HKCU_dataPath(m_path)
    Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & m_path & "; Extended Properties=dBASE IV"
    Const queryString As String = _
    "SELECT * FROM ARCUS01.dbf WHERE FCUSTNO = @FCUSTNO " & _
    " UPDATE ARCUS01.dbf " & _
    " SET " & _
    " FCOMPANY = 'Wiped Customer' " & _
    ", FADDR1 = @Empty " & _
    ", FADDR2 = @Empty " & _
    ", FCITY = @Empty " & _
    ", FSTATE = @Empty " & _
    ", FZIP = @Empty " & _
    ", FSADDR1 = @Empty " & _
    ", FSADDR2 = @Empty " & _
    ", FSCITY = @Empty " & _
    ", FSSTATE = @Empty " & _
    ", FSZIP = @Empty " & _
    ", FPHONE1 = @Empty " & _
    ", FFAX = @Empty " & _
    ", FFNAME = @Empty " & _
    ", FLNAME = @Empty " & _
    ", FTITLE = @Empty " & _
    ", FSALESPN = @Empty " & _
    ", FTERR = @Empty " & _
    ", FRESALENO = @Empty " & _
    ", FLPDATE = @Empty " & _
    ", FLPAMT = 0 " & _
    ", FATDSAMT = 0 " & _
    ", FYTDSAMT = 0 " & _
    " WHERE FCUSTNO = @FCUSTNO "

        Using connection As New System.Data.OleDb.OleDbConnection(connString)
            Using command As New System.Data.OleDb.OleDbCommand(queryString, connection)
    
                Dim paramWipe As System.Data.OleDb.OleDbParameter
                paramWipe = New System.Data.OleDb.OleDbParameter("@Empty", OleDbType.VarChar)
                paramWipe.Value = String.Empty
                command.Parameters.Add(paramWipe)
    
                Dim paramZero As System.Data.OleDb.OleDbParameter
                paramZero = New System.Data.OleDb.OleDbParameter("@Zero", OleDbType.Decimal)
                paramZero.Value = 0.0
                command.Parameters.Add(paramZero)
    
                Dim paramFCUSTNO As System.Data.OleDb.OleDbParameter
                paramFCUSTNO = New System.Data.OleDb.OleDbParameter("@FCUSTNO", OleDbType.VarChar)
                paramFCUSTNO.Value = p
                comm
    
    J J 2 Replies Last reply
    0
    • J jkirkerx

      This is the first I'm trying to update a row in a FoxPro DBF file. My code runs without error, but the row just won't update. I get a 0 back from ExecuteNonQuery I tried hard coding the customer number but same thing. Tried just updating 1 column FCOMPANY, same thing. I must be missing something here, like perhaps a cursor or something. The SELECT line was a feeble attempt to try something.

      Dim m_path As String = Nothing
      Dim dwXCode As Integer = registry_shared.read_HKCU_dataPath(m_path)
      Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & m_path & "; Extended Properties=dBASE IV"
      Const queryString As String = _
      "SELECT * FROM ARCUS01.dbf WHERE FCUSTNO = @FCUSTNO " & _
      " UPDATE ARCUS01.dbf " & _
      " SET " & _
      " FCOMPANY = 'Wiped Customer' " & _
      ", FADDR1 = @Empty " & _
      ", FADDR2 = @Empty " & _
      ", FCITY = @Empty " & _
      ", FSTATE = @Empty " & _
      ", FZIP = @Empty " & _
      ", FSADDR1 = @Empty " & _
      ", FSADDR2 = @Empty " & _
      ", FSCITY = @Empty " & _
      ", FSSTATE = @Empty " & _
      ", FSZIP = @Empty " & _
      ", FPHONE1 = @Empty " & _
      ", FFAX = @Empty " & _
      ", FFNAME = @Empty " & _
      ", FLNAME = @Empty " & _
      ", FTITLE = @Empty " & _
      ", FSALESPN = @Empty " & _
      ", FTERR = @Empty " & _
      ", FRESALENO = @Empty " & _
      ", FLPDATE = @Empty " & _
      ", FLPAMT = 0 " & _
      ", FATDSAMT = 0 " & _
      ", FYTDSAMT = 0 " & _
      " WHERE FCUSTNO = @FCUSTNO "

          Using connection As New System.Data.OleDb.OleDbConnection(connString)
              Using command As New System.Data.OleDb.OleDbCommand(queryString, connection)
      
                  Dim paramWipe As System.Data.OleDb.OleDbParameter
                  paramWipe = New System.Data.OleDb.OleDbParameter("@Empty", OleDbType.VarChar)
                  paramWipe.Value = String.Empty
                  command.Parameters.Add(paramWipe)
      
                  Dim paramZero As System.Data.OleDb.OleDbParameter
                  paramZero = New System.Data.OleDb.OleDbParameter("@Zero", OleDbType.Decimal)
                  paramZero.Value = 0.0
                  command.Parameters.Add(paramZero)
      
                  Dim paramFCUSTNO As System.Data.OleDb.OleDbParameter
                  paramFCUSTNO = New System.Data.OleDb.OleDbParameter("@FCUSTNO", OleDbType.VarChar)
                  paramFCUSTNO.Value = p
                  comm
      
      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      It's my parameter @FCUSTNO I think I can figure it out now, got a 1 back

      21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.

      1 Reply Last reply
      0
      • J jkirkerx

        This is the first I'm trying to update a row in a FoxPro DBF file. My code runs without error, but the row just won't update. I get a 0 back from ExecuteNonQuery I tried hard coding the customer number but same thing. Tried just updating 1 column FCOMPANY, same thing. I must be missing something here, like perhaps a cursor or something. The SELECT line was a feeble attempt to try something.

        Dim m_path As String = Nothing
        Dim dwXCode As Integer = registry_shared.read_HKCU_dataPath(m_path)
        Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & m_path & "; Extended Properties=dBASE IV"
        Const queryString As String = _
        "SELECT * FROM ARCUS01.dbf WHERE FCUSTNO = @FCUSTNO " & _
        " UPDATE ARCUS01.dbf " & _
        " SET " & _
        " FCOMPANY = 'Wiped Customer' " & _
        ", FADDR1 = @Empty " & _
        ", FADDR2 = @Empty " & _
        ", FCITY = @Empty " & _
        ", FSTATE = @Empty " & _
        ", FZIP = @Empty " & _
        ", FSADDR1 = @Empty " & _
        ", FSADDR2 = @Empty " & _
        ", FSCITY = @Empty " & _
        ", FSSTATE = @Empty " & _
        ", FSZIP = @Empty " & _
        ", FPHONE1 = @Empty " & _
        ", FFAX = @Empty " & _
        ", FFNAME = @Empty " & _
        ", FLNAME = @Empty " & _
        ", FTITLE = @Empty " & _
        ", FSALESPN = @Empty " & _
        ", FTERR = @Empty " & _
        ", FRESALENO = @Empty " & _
        ", FLPDATE = @Empty " & _
        ", FLPAMT = 0 " & _
        ", FATDSAMT = 0 " & _
        ", FYTDSAMT = 0 " & _
        " WHERE FCUSTNO = @FCUSTNO "

            Using connection As New System.Data.OleDb.OleDbConnection(connString)
                Using command As New System.Data.OleDb.OleDbCommand(queryString, connection)
        
                    Dim paramWipe As System.Data.OleDb.OleDbParameter
                    paramWipe = New System.Data.OleDb.OleDbParameter("@Empty", OleDbType.VarChar)
                    paramWipe.Value = String.Empty
                    command.Parameters.Add(paramWipe)
        
                    Dim paramZero As System.Data.OleDb.OleDbParameter
                    paramZero = New System.Data.OleDb.OleDbParameter("@Zero", OleDbType.Decimal)
                    paramZero.Value = 0.0
                    command.Parameters.Add(paramZero)
        
                    Dim paramFCUSTNO As System.Data.OleDb.OleDbParameter
                    paramFCUSTNO = New System.Data.OleDb.OleDbParameter("@FCUSTNO", OleDbType.VarChar)
                    paramFCUSTNO.Value = p
                    comm
        
        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        jkirkerx wrote:

        in a FoxPro DBF file.

        Presumably as a learning experience. I would suggests finding some other database to use if possible. I doubt knowing FoxPro is going to open any doors unless you are targeting some very specific organization. That is because it is no longer a commercial product (not even clear if there is any non-commercial use.)

        J 1 Reply Last reply
        0
        • J jschell

          jkirkerx wrote:

          in a FoxPro DBF file.

          Presumably as a learning experience. I would suggests finding some other database to use if possible. I doubt knowing FoxPro is going to open any doors unless you are targeting some very specific organization. That is because it is no longer a commercial product (not even clear if there is any non-commercial use.)

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          I don't use Fox Pro, it's just an app that a customer of mine has and it's quick money, but got it working last Friday.

          21st Century Globalism has become Socialism on a planetary scale, in which the unequal treaties of the past have come back into play.

          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