Mastering Development

is there a way of returning a bool value from db.Execute(sql) in C# mysql?

I am fiddling around with some mysql commands and would like to know how I can return a bool if my command was successful, here is some example code…

    public static bool RunSQL(string SQL)
            // Info: db is defined in my dependency service!
            bool execute = false;
            execute = Convert.ToBoolean(db.Execute(SQL));
            return execute;
        catch (Exception ex)
            GlobalErrorList.ErrorControler(ex.Message, "DatabaseManager", SQL, "RunSQL");
            return false;

My issue here is that db.Execute(sql) always returns 0 even when the command is successful, this I have checked in my database, for example the sql string is a string that is defined to create a table, it works fine, but the db.Execute(sql) returns 0;

My question is… Can anyone help my find a reliable way of returning the value of the executed string?

I.E true if was successful false if not!

Leave a Reply

Your email address will not be published. Required fields are marked *