西域诸国地图:SqlDataAdapter temp_ada = new SqlDataAdapter("select TOP 17 * from "+Lei+"",temp_con);

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 15:31:31
我是一个菜鸟,刚学编程。。。
这是asp.net的SQL语句,在浏览的时候说“第 1 行: 'from' 附近有语法错误。”

以下是源代码:
SqlConnection temp_con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter temp_ada = new SqlDataAdapter("select TOP 17 * from "+Lei+"",temp_con);
DataSet temp_dataset = new DataSet();
temp_ada.Fill(temp_dataset,"News1");
DataList1.DataSource = temp_dataset.Tables["News1"];
DataList1.DataBind();

谢谢大家。。。
Lei是我存储连接串的一个变量,用来存储数据库表的名称,谢谢。。。

没学过asp.net 不过看着好象是lei这个变量是空的 所以有错误
你找下lei是什么值

看看有没有这个数据库“+Lei+”存在。那就知道怎么做了