I have searched thoroughly, but could not find a way to SET my column data to the variable that I have initialized using a SQL UPDATE statement.
Here is the piece of code that is causing problem:
int maxId;
SqlConnection dataConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString) ;
SqlCommand dataCommand = new SqlCommand("select max(UserID) from Registration", dataConnection) ;
dataConnection.Open();
maxId = Convert.ToInt32(dataCommand.ExecuteScalar());
string Id = maxId.ToString();
// this next line is not working
SqlCommand _setvin = new SqlCommand("UPDATE Registration SET VIN=maxId , Voted=0 WHERE UserID=maxId", dataConnection);
_setvin.ExecuteNonQuery();
dataConnection.Close();
Please guide me on how I can correct the commented line above.