读书人

怎么动态的创建select语句.

发布时间: 2012-01-23 21:57:28 作者: rapoo

如何动态的创建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 信息表 ";

我一般用这个控件

读书人网 >asp.net

热点推荐