Hi I have a method which updates a MySQL table using a query. I\'m using a MS Visual Studio and phpmyadmin as the SQL client.
Method:
public static Memb
An alternative to the post of @Sajeetharan is that you return the value of your ExecuteNonQuery call
connection.Open();
cmd = connection.CreateCommand();
cmd.CommandText = query;
return cmd.ExecuteNonQuery();
Of course you also have to return something at the end of your method (after the finally block).
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
Reference
Commonly, we need't return object like Member
when update/insert or delete. We should return just a Boolean flag or return Nothing.
If you return flag, you should set it as result of cmd.ExecuteNonQuery() > 0
and also in Catch
brand.
If you return nothing, just modify your method to
public static void updateMember(...)
{
....
}
Your method is not returning anything, You need to return the Member Object.
If you do not need to return anything , just change your Method Signature like this,
public static Void updateMember(string un, string pass, string name, string surname,string mf, string dob, string add, string phone, string email)