string str = comboBox1.Text;
List<string> list = new List<string>();
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=qiyun3d;Integrated Security=True");
conn.Open();
SqlCommand sqlCmd = new SqlCommand(" select * from"+str), conn);
//意思是这样,表名称要从combobox当前的选项获取,但这样写不对
SqlDataReader reader =sqlCmd.ExecuteReader();
//取字段
for(int i=0;i<=reader.FieldCount-1;i++)
{
list.Add(reader.GetName(i)); //获取所有字段以后还要存到这里面
}
求教应该怎么改?或者方法不对重新写?