Oladotun Obileye

Oladotun Obileye

  • 1.7k
  • 98
  • 2.8k

how to connect database to bootstrap html table in asp webfo

May 4 2019 1:34 AM
Good day everyone i am working on a project on asp.net webform. i am using a template that has an already made table so i want to collect the table to the database so it can fetch out all the information and send it to the table.
  1. StringBuilder table = new StringBuilder();  
  2. protected void Page_Load(object sender, EventArgs e)  
  3. {  
  4. if(!Page.IsPostBack)  
  5. {  
  6. SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\odt\Documents\login.mdf;Integrated Security=True;Connect Timeout=30");  
  7. ;  
  8. con.Open();  
  9. SqlCommand cmd = new SqlCommand();  
  10. cmd.CommandText = "select * from [log] ";  
  11. cmd.Connection = con;  
  12. SqlDataReader dt = cmd.ExecuteReader();  
  13. if (dt.HasRows)  
  14. {  
  15. if (dt.Read())  
  16. {  
  17. }  
  18. }  
  19. // cmd.ExecuteNonQuery();  
  20. con.Close();  
  21. }  
this is the html table
  1. <div class="box-body table-responsive no-padding">  
  2. <table ID="tdb" class="table table-hover" >  
  3. <tr>  
  4. <th>ID</th>  
  5. <th>User</th>  
  6. <th>Password</th>  

Answers (4)