c# - remove each listbox1 items after running the query? -
i have items inside listbox1 , want use each items run query, once query runned, want delete item inside listbox , use next item run query. example if item1 used delete item1 , use next item inside listbox run query.do items till no items left inside listbox1.
foreach (string myitems in listbox1.items) { using (oraclecommand crtcommand = new oraclecommand(select regexp_replace(dbms_metadata.get_ddl('" + myitems + "'), conn1)) { string expectedresult = "y"; string dataresult = crtcommand.executescalar().tostring(); if (expectedresult == dataresult) { //do , remove item has been used run query. } else { } } }
you cannot directly in foreach loop. give exception 'collection modified; enumeration operation may not execute' if try inside foreach loop. rather after executing entire query can delete them all.
listbox1.items.clear();
incase want keep track of items have been executed can create
hashset<int> ids = new hashset<int>(); ids.add(youridtoadd);
and add executed ids in that.
Comments
Post a Comment