【发布时间】:2008-11-20 19:59:35
【问题描述】:
我一直认为在后面的代码中编写 SQL 查询与使用 SqlDataSource 编写相比并不好
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "Categories");
myGridView.DataSource = ds;
myGridView.DataBind();
对比
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConnection %>"
SelectCommand="SELECT * FROM Categories" />
我觉得使用SqlDataSource 是安全的,易于维护。 我的担心是真的吗?请辩解。
【问题讨论】: