ASP.NET Query from codebehind (Old School)


/ Published in: C#
Save to your folder(s)

Old school or simple way of querying data without a DAL.


Copy this code and paste it in your HTML
  1. SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Product", ConfigurationManager.ConnectionStrings["ConnectionStringValue"].ConnectionString);
  2. DataTable table = new DataTable();
  3. adapter.Fill(table);
  4. Repeater1.DataSource = table;
  5. Repeater1.DataBind();
  6.  
  7. //Access data in .aspx with <%#Eval("fieldName")%>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.