c# - How to Insert label value into MS Access Database -
i tried inserting label value ms access codes below keep getting "syntax error in insert statement". please help. thanks
private void button1_click(object sender, eventargs e) { label2.text = "born win"; label4.text = "£10"; connection = new oledbconnection(@"provider=microsoft.ace.oledb.12.0;data source =c:\users\kunle\documents\winners app\winnersbookshop.accdb;persist security info=false"); connection.open(); oledbcommand command = new oledbcommand(); command.connection = connection; try { command.commandtext = "insert transaction([title], [price]) values('" + label2.text + "','" + label4.text + "')"; command.commandtype = commandtype.text; command.executenonquery(); messagebox.show("successfully"); } catch (exception r) { messagebox.show("unsuccesssful" + r); }
Comments
Post a Comment