I am having an issue with my update code, error converting varchar to numeric is creating an exception. It is dealing with two tables.
table1(WEB_ADDRESS) consists of address information That is sent to a geocoding API service.
|PKID | ADDRESS_ID | ADDRESS_1 | CITY | etc...
table2(WEB_ADDRESS_GEO) consists lattitudes and longitudes recieved from the API service.
ADDRESS_ID | Lat | Lng
I need to update the rows of data in table 2 with lats and lngs to match the address data in table 1.
here is the code here
using (SqlConnection myConnection = new SqlConnection(context))
{
myConnection.Open();
string strQueryUpdate = "UPDATE WEB_ADDRESS_GEO SET Lat = '" + strLat + "', Lng = '" + strLng + "'" + "WHERE ADDRESS_ID=" + row.ADDRESS_ID;
SqlCommand myCommandUpdate = new SqlCommand(strQueryUpdate, myConnection);
myCommandUpdate.ExecuteNonQuery();
the column ADDRESS_ID is of type VarChar, Lat and Lng are of type decimal.
Note : sql injection is avoided as there will never be user input.