c# - Whenever I Insert Data in Database It Saves an Extra Row in Database -


layout , db

if (!(string.isnullorempty(b.tostring()))) {     string connection = "server=127.0.0.1; database=accounts;user=root; password='';";     mysqlconnection conn = new mysqlconnection(connection);     conn.open();     string sql = "insert payment_voucher (voucher_no, paid_to, date, account_cr, account_dr, description, student_emp_id, amount, total ) values ('" + label8.text.tostring() + "','" + textbox1.text + "', '" + datetimepicker1.value + "','" + + "','" + b + "', '" + richtextbox1.text + "', '" + textbox3.text + "', '" + textbox4.text + "', '" + label11.text.tostring() + "');";     mysqlcommand command = new mysqlcommand(sql, conn);     command.executenonquery();     conn.close();  } 

i dont know why happening. front end in c#.

that statement not insert 2 rows.

you have few things check here:

  • check if code being called twice
  • check if there other similar code being called
  • make sure there no triggers on table additional insert
  • make sure don't have weird try/catch/fail logic causes entire thing run again

and importantly:

  • run sql profiler trace see being sent database

query table when you've checked raw select query in enterprise manager , make sure there 1 row.

that code above not duplicate rows unless called twice.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -