I decided to experiment with the code below. I did a check and both AreaID and Area have the right values. I think that it might have to do something with my if statements or SQL Server. But it didn't work because I got the following error message:
Microsoft OLE DB Provider for SQL Server error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Here's the code that I tried to use:
'Build the sql query used to fill the select element
sql = "select IsNull(AreaID, 0) as AreaID from City"
sql = sql & " where City= '" & hidCity & "'"
sql = sql & " and State= '" & hidState & "'"
'Create a recordset
set rsCity = Server.CreateObject("ADODB.Recordset")
rsCity.Open sql, connectionString, adOpenDynamic, adLockOptimistic
If rsCity.EOF then
'Area doesn't exist in state
Response.write(hidCity & " in " & hidState & " does not exist in database")
Else
'Area does exist in DB
'Check to see if the database already has this area
If CLng(Area) <> CLng(rsCity("AreaID")) then
'Move to the next recordset
rsCity.MoveFirst
rsCity("AreaID") = Area
rsCity.update
End If
End If