Your second query looks good, but if userid is a numeric field, use following
String query = "Update masterusertable set username='" + txtName.Text + "', password='" + txtpassword.Text + "', phoneno='" + txtphoneno.Text + "', adress='" + rtxtAdress.Text + "' where userid =" + txtuserid.Text;