Tuesday, 15 July 2014

c# - Is there a way to test which combinations return a result? -



c# - Is there a way to test which combinations return a result? -

ok, clarify, have method gets string database, depending on input form form, series of 4 combo boxes.

thing is, in db, entries missing fields, meaning queries homecoming nothing.

is there way automatically test fields won't homecoming value, or improve alter query?

here's current code:

form:

private void cmbcorecfg_selectedindexchanged(object sender, eventargs e) { if (cmbcorecfg.text != "" && cmbmetal.text != "") { cableid_controller.getsupplierid(this); } }

controller:

public static void getsupplierid(cableid_createview cview) { supplierid_controller.smodel = new supplierid_model(); supplierid_controller.smodel.supplierid = 3; supplierid_controller.smodel.coreconfig = cview.cmbcorecfg.text; supplierid_controller.smodel.insulation = cview.cmbinsulation.text; supplierid_controller.smodel.xsec = cview.cmbxsec.text.split(new[] { ' ' }, stringsplitoptions.removeemptyentries)[0]; supplierid_controller.smodel.condconfig = condcfg = cview.cmbxsec.text.split('-')[1].trim(); supplierid_controller.smodel.metal = cview.cmbmetal.text; database_facade.operation_switch(supplierid_controller.opread); cview.txtproductcode.text = supplierid_controller.smodel.prdtcd; }

database query:

{ mysqlcommand = mysqlconnect.createcommand(); mysqlcommand.commandtext = "select prdtcd supplierinfo xsec = @xsec , coreconfg = @coreconfg , condconfg = condconfg " + "and insul = @insul , metal = @metal;"; mysqlcommand.parameters.add("@xsec", mysqldbtype.varchar); mysqlcommand.parameters.add("@coreconfg", mysqldbtype.varchar); mysqlcommand.parameters.add("@condconfg", mysqldbtype.varchar); mysqlcommand.parameters.add("@insul", mysqldbtype.varchar); mysqlcommand.parameters.add("@metal", mysqldbtype.varchar); mysqlcommand.parameters["@xsec"].value = smodel.xsec; mysqlcommand.parameters["@coreconfg"].value = smodel.coreconfig; mysqlcommand.parameters["@condconfg"].value = smodel.condconfig; mysqlcommand.parameters["@insul"].value = smodel.insulation; mysqlcommand.parameters["@metal"].value = smodel.metal; mysqlreader = mysqlcommand.executereader(); while (mysqlreader.read()) { smodel.prdtcd = convert.tostring(mysqlreader["prdtcd"]); } mysqlreader.close(); mysqlcommand.executenonquery(); }

c# mysql

No comments:

Post a Comment