i trying set method allows me archive record has been returned via search box.
i have got search query working when run update query, record still appears when searched for.
can help?
namespace test_application { public partial class form1 : form { public form1() { initializecomponent(); } private void button1_click(object sender, eventargs e) { this.close(); mainmenu mmform = new mainmenu(); mmform.show(); } private void textbox3_textchanged(object sender, eventargs e) { } private void button2_click(object sender, eventargs e) { system.data.oledb.oledbconnection conn = new system.data.oledb.oledbconnection(); conn.connectionstring = @"provider=microsoft.jet.oledb.4.0;data source=boilersvc_be.mdb"; try { conn.open(); oledbcommand command = new oledbcommand("select equipment.custid custid,equipment.manufacturer manufacturer,equipment.model model, equipment.lastservice lastservice,initial,surname,[address 1],[address 2],[address 3],[post town],[post code],telephone contacts inner join equipment on equipment.custid = contacts.custid contacts.archived = 0 , surname = '" + textbox3.text + "' or initial = '" + textbox3.text + "' or[post town] = '" + textbox3.text + "' or[post code] = '" + textbox3 + "'", conn); oledbdatareader reader = command.executereader(); while (reader.read()) { int result; customid.text = reader["custid"].tostring(); firstname.text = reader["initial"].tostring(); lastname.text = reader["surname"].tostring(); address1.text = reader["address 1"].tostring(); address2.text = reader["address 2"].tostring(); address3.text = reader["address 3"].tostring(); towncity.text = reader["post town"].tostring(); postcode.text = reader["post code"].tostring(); telephone.text = reader["telephone"].tostring(); lstsvcdat.text = reader["lastservice"].tostring(); boilman.text = reader["manufacturer"].tostring(); boilmod.text = reader["model"].tostring(); result = convert.toint32(customid.text); } } { conn.close(); } } private void button3_click(object sender, eventargs e) { if (string.isnullorempty(lastname.text)) { messagebox.show("please search customer first"); } else { system.data.oledb.oledbconnection conn = new system.data.oledb.oledbconnection(); conn.connectionstring = @"provider=microsoft.jet.oledb.4.0;data source=boilersvc_be.mdb"; try { conn.open(); oledbcommand command = new oledbcommand("update contacts set archived = 1 custid = @custid", conn); command.parameters.add(new oledbparameter("@pcustid", customid.text)); oledbdatareader reader = command.executereader(); } { conn.close(); customid.text = null; firstname.text = null; lastname.text = null; address1.text = null; address2.text = null; address3.text = null; towncity.text = null; postcode.text = null; telephone.text = null; lstsvcdat.text = null; boilman.text = null; boilmod.text = null; messagebox.show("customer archived"); } } } private void form1_load(object sender, eventargs e) { } } }
i suspect error in search query. when parenthesis omitted order of and's , or's grouped. try:
where contacts.archived = 0 , ((surname = '" + textbox3.text + "' or initial = '" + textbox3.text + "') or ([post town] = '" + textbox3.text + "' or[post code] = '" + textbox3 + "'))"
Comments
Post a Comment