I have a table in Access with 2 columns WELL_NO and PUMPER. Both are TEXT. I want to update the PUMPER column from a text to a number starting with 900. Multiple WELL_NO can have the same PUMPER. For instance:
WELL_NO PUMPER
D7645 SA3
RA87 FR1
TP875 SA3
becomes:
WELL_NO PUMPER
D7645 900
RA87 901
TP875 900
The below code works very well in B4A (Thank goodness for B4A). I am curious to see the equivalent code in Access VB. Thank you
WELL_NO PUMPER
D7645 SA3
RA87 FR1
TP875 SA3
becomes:
WELL_NO PUMPER
D7645 900
RA87 901
TP875 900
The below code works very well in B4A (Thank goodness for B4A). I am curious to see the equivalent code in Access VB. Thank you
B4X:
Sub ConvertPumperToNumber
Dim txt2, MyPumper, MyInitials As String
Dim Cursor1 As Cursor
txt="SELECT DISTINCT PUMPER FROM " & DBTableName & " WHERE PUMPER IS NOT NULL OR PUMPER ='' "
Cursor1=SQL1.ExecQUERY(txt)
Dim cursor2 As Cursor
txt2="SELECT * FROM " & DBTableName & " WHERE PUMPER IS NOT NULL OR PUMPER ='' "
cursor2=SQL1.EXECQUERY(txt2)
Dim J As Int=900
For i= 0 To Cursor1.rowcount -1
Cursor1.position=i
MyPumper=Cursor1.getstring("PUMPER")
For k=0 To cursor2.rowcount-1
cursor2.position=k
MyInitials=cursor2.getstring("PUMPER")
If MyInitials=MyPumper Then
txt="UPDATE " & DBTableName &" SET PUMPER = ? WHERE PUMPER=?"
SQL1.ExecNonQuery2(txt, Array As Object(J+i, MyInitials ) )
End If
Next
Next
Cursor1.close
cursor2.close
End Sub