Advertisement
Guest User

Untitled

a guest
Apr 12th, 2019
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 2.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9. using System.Text;
  10.  
  11. public partial class userinfo : System.Web.UI.Page
  12. {
  13.  
  14.  
  15.  
  16.     SqlConnection scon = new SqlConnection(@"User id=sa;Password=123;Server=.\sqlexpress03;Database=event");
  17.     StringBuilder htmlTable = new StringBuilder();
  18.     protected void Page_Load(object sender, EventArgs e)
  19.     {
  20.           string a = Session["username"].ToString();
  21.  
  22.              using (SqlCommand scmd = new SqlCommand())
  23.             {
  24.                 scmd.Connection = scon;
  25.                 scmd.CommandType = CommandType.Text;
  26.             scmdselect.Parameters.Add("@Username", SqlDbType.VarChar, 50).Value = Username;
  27.             scmd.CommandText = "SELECT * FROM registered where username = @a";
  28.                 scon.Open();
  29.                 SqlDataReader articleReader = scmd.ExecuteReader();
  30.  
  31.                 htmlTable.Append("<table border='1'>");
  32.                 htmlTable.Append("<tr><th>SlNo.</th><th>Name</th><th>Mobile Number</th><th>EmailId</th></tr>");
  33.  
  34.                 if (articleReader.HasRows)
  35.                 {
  36.                     while (articleReader.Read())
  37.                     {
  38.                         htmlTable.Append("<tr>");
  39.                         htmlTable.Append("<td>" + articleReader["userid"] + "</td>");
  40.                         htmlTable.Append("<td>" + articleReader["username"] + "</td>");
  41.                         htmlTable.Append("<td>" + articleReader["email"] + "</td>");
  42.                         htmlTable.Append("<td>" + articleReader["createddate"] + "</td>");
  43.                         htmlTable.Append("</tr>");
  44.                     }
  45.                     htmlTable.Append("</table>");
  46.  
  47.                     PlaceHolder1.Controls.Add(new Literal { Text = htmlTable.ToString() });
  48.  
  49.                     articleReader.Close();
  50.                     articleReader.Dispose();
  51.                 }
  52.             }
  53.         }
  54.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement