当前位置: 代码迷 >> ASP.NET >> 怎么动态的创建select语句.
  详细解决方案

怎么动态的创建select语句.

热度:5745   发布时间:2013-02-26 00:00:00.0
如何动态的创建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 信息表 ";

我一般用这个控件
  相关解决方案