我想使用每个 listbox1 项目来运行两个查询,如果两个结果不同,则将该项目移动到另一个名为 listbox2 的列表框,如果它们相同,则从 listbox1 中删除该项目。
foreach (string Items in listBox1.Items)
{
using (OracleCommand crtCommand = new OracleCommand("select count(*) from(( select * from all_ind_columns where index_name= '" + Items + "' and table_owner='" + txtSrcUserID.Text.ToUpper() + "'))", conn1))
using (OracleCommand ctCommand = new OracleCommand("select count(*) from(( select * from all_ind_columns where index_name= '" + Items + "' and table_owner='" + txtDesUserID.Text.ToUpper() + "'))", conn1))
{
string result1 = crtCommand.ExecuteScalar().ToString();
string result2 = ctCommand.ExecuteScalar().ToString();
if (result1 != result2)
{
//move that item to listbox2
}
else if(result1 == result2)
{
// remove that item from listbox1
}
}
}