Hi All, I can add and erase Coordinate Points from a Database, but am baffled why my coding to update a Coordinate is not working. I do not use the "ID", but rather the name of the Coordinate Point. Herewith my Code:
Sub StoreCoords
If CoordName.Text<>"" Then
SelectCoordType
ResultSet =CGlobals.SQL1.ExecQuery2(Query, Array As String (CoordName.Text))
If ResultSet.NextRow = True Then
'if it exists show a message and do nothing else
Msgbox2Async("Override?", "Coord Exists", "Yes", "No", "", Null,False)
Wait For Msgbox_Result (Answ As Int)
If Answ = DialogResponse.POSITIVE Then 'if yes, delete the entry
AmendCoord
Else
CoordName.RequestFocus
Return
End If
Else
'if not, add the Coord
If CGlobals.CoordCode=1 Then
'Site Coords
Query = "INSERT INTO SCoords VALUES (?,?,?,?,?)"
else if CGlobals.CoordCode=2 Then
'Global Coords
Query = "INSERT INTO GCoords VALUES (?,?,?,?,?)"
Else
'Job Coords
Query = "INSERT INTO Coords VALUES (?,?,?,?,?)"
End If
CGlobals.SQL1.ExecNonQuery2(Query, Array As String(CoordName.Text, CoordEast.Text, CoordNorth.Text,Elevation.Text,CoordDescription.text))
ToastMessageShow("Coord Added", False)
End If
Else
Msgbox2Async("Not Enough Data Entered", "Missing Data", "OK", "", "", Null,False)
Return
End If
ResultSet.Close
End Sub
Here I want to save a Point, but the program first checks if the Point exists and if so, the program goes to the following routine and should update the info about the point:
Sub AmendCoord
'Main.SQL1.ExecNonQuery2("UPDATE TKRecordTemp SET Sent=?, Success=? WHERE OSID = ?",Array As String(1,1,1231234105))?
If CGlobals.CoordCode=1 Then
'Site Coords
Query = "UPDATE SCoords Set Name = ?, East = ?, North = ?, Elevation = ?, Description = ? WHERE Name = ? "
else if CGlobals.CoordCode=2 Then
'Global Coords
Query = "UPDATE GCoords Set Name = ?, East = ?, North = ?, Elevation = ?, Description = ? WHERE Name = ?"
Else
'Job Coords
Query = "UPDATE Coords Set East = ?, North = ?, Elevation = ?, Description = ? WHERE Name = ?"
End If
CGlobals.SQL1.ExecNonQuery2(Query, Array As String(CoordName.Text, CoordEast.Text,CoordNorth.Text,Elevation.Text,CoordDescription.text))
ToastMessageShow("Entry Updated", False) 'display a confirmation message
End Sub
Sub StoreCoords
If CoordName.Text<>"" Then
SelectCoordType
ResultSet =CGlobals.SQL1.ExecQuery2(Query, Array As String (CoordName.Text))
If ResultSet.NextRow = True Then
'if it exists show a message and do nothing else
Msgbox2Async("Override?", "Coord Exists", "Yes", "No", "", Null,False)
Wait For Msgbox_Result (Answ As Int)
If Answ = DialogResponse.POSITIVE Then 'if yes, delete the entry
AmendCoord
Else
CoordName.RequestFocus
Return
End If
Else
'if not, add the Coord
If CGlobals.CoordCode=1 Then
'Site Coords
Query = "INSERT INTO SCoords VALUES (?,?,?,?,?)"
else if CGlobals.CoordCode=2 Then
'Global Coords
Query = "INSERT INTO GCoords VALUES (?,?,?,?,?)"
Else
'Job Coords
Query = "INSERT INTO Coords VALUES (?,?,?,?,?)"
End If
CGlobals.SQL1.ExecNonQuery2(Query, Array As String(CoordName.Text, CoordEast.Text, CoordNorth.Text,Elevation.Text,CoordDescription.text))
ToastMessageShow("Coord Added", False)
End If
Else
Msgbox2Async("Not Enough Data Entered", "Missing Data", "OK", "", "", Null,False)
Return
End If
ResultSet.Close
End Sub
Here I want to save a Point, but the program first checks if the Point exists and if so, the program goes to the following routine and should update the info about the point:
Sub AmendCoord
'Main.SQL1.ExecNonQuery2("UPDATE TKRecordTemp SET Sent=?, Success=? WHERE OSID = ?",Array As String(1,1,1231234105))?
If CGlobals.CoordCode=1 Then
'Site Coords
Query = "UPDATE SCoords Set Name = ?, East = ?, North = ?, Elevation = ?, Description = ? WHERE Name = ? "
else if CGlobals.CoordCode=2 Then
'Global Coords
Query = "UPDATE GCoords Set Name = ?, East = ?, North = ?, Elevation = ?, Description = ? WHERE Name = ?"
Else
'Job Coords
Query = "UPDATE Coords Set East = ?, North = ?, Elevation = ?, Description = ? WHERE Name = ?"
End If
CGlobals.SQL1.ExecNonQuery2(Query, Array As String(CoordName.Text, CoordEast.Text,CoordNorth.Text,Elevation.Text,CoordDescription.text))
ToastMessageShow("Entry Updated", False) 'display a confirmation message
End Sub