sql - How can I update/delete data on my table in C# using OOP? -


i'm done adding of data on table , works fine. i'm done coding update , delete function on class, it's not updating table. no errors found on program.

here's code:

public void studentupdate(string id, string lastname, string firstname, string middlename, string suffix, string age, string gender, string paddress, datetime birthday) {     result.query = "update tbl_student set lastname = '" + lastname + "', firstname = '" + firstname + "', middlename = '" + middlename + "', suffix = '" + suffix + "', age = '" + age + "', gender = '" + gender + "', pmt_address = '" + paddress + "', birthday = to_date('" + string.format("{0:mm/dd/yyyy}", birthday.toshortdatestring()) + "','mm/dd/yyyy') std_id = '" + id + "'";     result.transaction = true;     result.executenonquery();     studentcommit();     result.close(); }  public void studentdelete(string id) {     result.query = "delete tbl_student std_id = '" + id + "'";     result.executenonquery();     studentcommit();     result.close(); }  public void studentcommit() {     if (!result.commit())     {         result.rollback();     } } 

additionally, have created user login account creation code in table (update/delete function) working good. difference that, have 3 strings on login table while in student table have many strings plus 1 datetime.

most select part of update statement isn't locating records: http://weblogs.asp.net/stevewellens/why-sql-updates-fail-three-reasons

and, others pointed out, building strings doing makes code vulnerable sql injection. if it's internal application or homework, it's not big deal, otherwise should using parametrized queries.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -