日期:2014-05-20  浏览次数:20422 次

如何动态的创建select语句...
select   col1,col2,col3.....from   table
col1,col2,col3....是不固定的,不知道数量不知道名称,使用一个listbox获取,但是获取后的值怎样放到select....from   table   里面   ??

谢谢   !!

------解决方案--------------------
string strSQL = "select " foreach(LiteItem item in this.ListBox1) { strSQL += item.value + ", "; } //....
------解决方案--------------------
for(int i=0;i <this.CheckBoxList1.Items.Count;i++)
{
if(this.CheckBoxList1.Items[i].Selected==true)
{
reciever+=this.CheckBoxList1.Items[i].Text+ ', ';
}

}
reciever=reciever.Trim( ', ');
this.sqlCommand1.CommandText= "select "+ ' '+reciever+ ' '+ "from 信息表 ";

我一般用这个控件