Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. protected void NumOfUsrBtn_Click(object sender, EventArgs e)
  2. {
  3.  
  4.  
  5.  
  6. using (var conn = new SqlConnection(sc))
  7. {
  8. string UsrNumSQL = "SELECT COUNT (UsrID)FROM UserInfo WHERE 1=1 AND Country = @cou AND State=@sta";
  9.  
  10. using (var cmd = new SqlCommand(UsrNumSQL, conn))
  11. {
  12. cmd.CommandType = CommandType.Text;
  13. cmd.CommandTimeout = 10000;
  14.  
  15.  
  16.  
  17. string condition = "";
  18.  
  19. if (worlddrdolist.SelectedValue != "")
  20. {
  21. condition += " and Country='" + worlddrdolist.SelectedValue + "'";
  22. }
  23. if (staatddl.SelectedValue != "")
  24. {
  25. condition += " and State='" + staatddl.SelectedValue + "'";
  26. }
  27. cmd.Connection.Open();
  28.  
  29. NumbOfUsersLbl.Text = cmd.ExecuteScalar().ToString();
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement