Updating a FoxPro dbf file using VB.net
-
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
-
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
-
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
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.)
-
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.)