Writing Queries in Code Compared to SqlDataSource

I always have the assumption that writing SQL queries in the code behind is not as good as writing it with SqlDataSource

SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection);

DataSet ds = new DataSet();

ad.Fill(ds, "Categories");

myGridView.DataSource = ds;

myGridView.DataBind();

against.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
  ConnectionString="<%$ ConnectionStrings:myConnection %>"
  SelectCommand="SELECT * FROM Categories" />

I feel that using SqlDataSource is safe, easily supported. Is my concern true? Please confirm.

+3
source share
7 answers

SQL queries in codes and SQL queries in SqlDataSource are pretty much equivalent

they are both the same in safety; since to simplify maintenance in most cases, SqlDataSource may be a little easier

, SqlDataSource . , , - /; -)

+8

SQL- . ?

, ? .

, ? .

, SQL- . , "" SqlDataSource. .

+13

, . aspx , , SQL- SqlDataSources. - .

, Microsoft SqlDataSources .NET 2.0: , .

, , , , ObjectDataSource. ODS , .

+3

SQL aspx aspx.cs - , . n-level/n-layer, .

+2

, SQLDataSource , , . - ( ), . - SQLDataSource SQL . SQLDataSource.

, , , . , . , NHibernate LinqToSql, .

+1

DataSource . . , - db, sqldatasource, , .

- , .

0

SQLDataSources , . SQLDataSource . Telerik , , . , , , , , sql . SQL- - .

0

All Articles