code_junkie

Writing queries in code behind vs. SqlDataSource

Nov 12th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection);
  2.  
  3. DataSet ds = new DataSet();
  4.  
  5. ad.Fill(ds, "Categories");
  6.  
  7. myGridView.DataSource = ds;
  8.  
  9. myGridView.DataBind();
  10.  
  11. <asp:SqlDataSource ID="SqlDataSource1" runat="server"
  12. ConnectionString="<%$ ConnectionStrings:myConnection %>"
  13. SelectCommand="SELECT * FROM Categories" />
Add Comment
Please, Sign In to add comment