Background
Currently working on a plugin in ArcMap done in VBA from early 2000 and refactoring it to VB.NET. The database is a MS Access Database.
Pretty new to VB.NET and coding in general.
Error
The issue I'm facing is that I'm getting the error:
InvalidCastException was unhandled.
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Operator '&' is not defined for string "UPDATE CustomerArea SET Area_m2=547," and type 'InternalField'.
Code
Dim nr
Dim area_polygon_excl_faktor As Double
Dim area_db
Do While Not AdoRS.BOF
nr = AdoRS("nr")
area_db = CDbl(AdoRS("area_m2").Value)
Dim result As MsgBoxResult
result = MsgBox(aAttrID(index) & " " & area_db & " " & area_polygon_exkl_faktor & " Would you like to update the area?", vbYesNoCancel, "Update of area")
If result = MsgBoxResult.Yes Then
strSqlUpdateArea = "UPDATE CustomerArea SET Area_m2='" & area_polygon_excl_faktor & "' WHERE Nr= '" & nr
AdoConn.Execute(strSqlUpdateArea)
ElseIf result = MsgBoxResult.No Then
MsgBox("You have decided not to update the area")
End If
The AdoRS is an ADODB.Recordset. The issue I am facing is on the line:
strSqlUpdateArea = "UPDATE CustomerArea SET Area_m2='" & area_polygon_excl_faktor & "' WHERE Nr= '" & nr
I've tried rewriting it several times and even adding a Convert.toString in the line nr = AdoRS("nr"), but with no luck. I know that the Nr in Access is an AutoNumber (LongInteger).
Then no quotes, and force a decimal separator to a dot: