c# - Not executing second query? -
when click button, first query gets executed. second 1 insert afspraken (behandeling)
doesn't execute. knows why?
private void button1_click(object sender, eventargs e) { string insertstatement = "insert afspraken (afspraakdatum) values ('" + textbox23.text + "');"; string insertstatement1 = "insert afspraken (behandeling) values ('" + textbox21.text + "');"; oledbcommand insertcommand = new oledbcommand(insertstatement, connection); oledbcommand insertcommand1 = new oledbcommand(insertstatement1, connection); connection.open(); try { int count = insertcommand.executenonquery(); } catch (oledbexception ex) { } { connection.close(); textbox23.clear(); textbox21.clear(); messagebox.show("uw afspraak gemaakt!"); } }
as saw in comments on answer, believe solution work best you:
string insertstatement = "insert afspraken (afspraakdatum, behandeling) values ('" + textbox23.text + "', '" + textbox21.text + "');"); oledbcommand insertcommand = new oledbcommand(insertstatement, connection);
but remember code unsafe, should use prepared statements instead.
Comments
Post a Comment