IM创造世界粮食计划署应用程序,我想检索表的DataGridView 在列表框中选择的多值,渐渐从列表框中选择的所有数据,因此其主要思想 是从SQL将此查询申请检索与多或
select * from Vwtb where firstname='' or firstaname='' or ..
我有while循环试图搜查了很多,但没有奏效,这是我的代码,请如果一些奇怪的事情为你即时通讯不专业:)
string[] orand = { "or"+listBox1.Text };
foreach (string sm in orand)
{
cn.Open();
string select = "select * from productvw where firstname='" + sm + "'";
SqlDataAdapter dataAdapter = new SqlDataAdapter(select, cn);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataTable ds = new DataTable();
dataAdapter.Fill(ds);
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = ds;
cn.Close();
}
任何类型的帮助会因此感激.. ..
我认为这将是更好的获得所有的名字,然后查询一次像'select * from Vwtb where'firstaname in('','',''...' –