Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. if (!Page.IsPostBack)
  4. {
  5. customerInformation();
  6.  
  7. }
  8. }
  9.  
  10. protected void ddNames_SelectedIndexChanged(object sender, EventArgs e)
  11. {
  12. customerInformation();
  13. }
  14.  
  15. private void customerInformation()
  16. {
  17. string dbString = ConfigurationManager.ConnectionStrings["TechSupportDBConString"].ConnectionString;
  18. string query = "SELECT * FROM Customers WHERE Name='" + ddNames.Text + "'";
  19.  
  20. SqlConnection Connection = new SqlConnection(dbString);
  21. Connection.Open();
  22.  
  23. SqlCommand Com = new SqlCommand(query, Connection);
  24. SqlDataReader reader = Com.ExecuteReader();
  25. if (reader.Read())
  26. {
  27. lblName.Text = reader["Name"].ToString() + "'s Personal Information";
  28. lblAddress.Text = reader["Address"].ToString() + "n" + reader["City"].ToString() + " " + reader["State"].ToString() + " " + reader["ZipCode"].ToString();
  29. lblPhone.Text = reader["Phone"].ToString();
  30. lblEmail.Text = reader["Email"].ToString();
  31.  
  32. reader.Close();
  33. Connection.Close();
  34. }
  35. }
  36.  
  37. SqlDataReader reader = command.ExecuteReader();
  38. if (reader.HasRows)
  39. {
  40. while (reader.Read())
  41. {
  42. //populate fields from reader
  43. }
  44. }
  45. else
  46. {
  47. lbl.Text = "No records found.";
  48. }
  49.  
  50. reader.Close();
  51. Connection.Close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement