c# - error insert query after install application -
i testing program , when runed in vs without error execute ! code :
private void button1_click(object sender, eventargs e) { oledbconnection conect = new oledbconnection(); conect.connectionstring = "provider=microsoft.jet.oledb.4.0;" + "data source=university.mdb;jet oledb:database password=sa@a"; conect.open(); oledbcommand o1 = new oledbcommand(); o1.connection = conect; if(button1.text=="save") o1.commandtext = "insert check_user(name_user,pw_user)values('" + textbox1.text + "','" + textbox2.text + "')"; else o1.commandtext = " select * check_user (name_user = '" + textbox1.text + "') , (pw_user = '" + textbox2.text + "' )"; o1.executenonquery(); if (button1.text != "save") { if (o1.executescalar() == null) messagebox.show("wrong user"); else { groupbox1.visible = false; menustrip1.visible = true; } } else { groupbox1.visible = false; menustrip1.visible = true; } conect.close(); }
but when execute after install app , run query error occurs : http://s4.picofile.com/file/8184692692/qq.png query select without error executed query insert or delete occurs error please me
you can't use nonquery "select". try this
if(button1.text=="save") { o1.commandtext = "insert check_user(name_user,pw_user)values('" + textbox1.text + "','" + textbox2.text + "')"; o1.executenonquery(); } else { o1.commandtext = " select * check_user (name_user = '" + textbox1.text + "') , (pw_user = '" + textbox2.text + "' )"; o1.executequery(); }
Comments
Post a Comment