Guest User

Untitled

a guest
Jun 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. try
  2. {
  3. SqlConnection con = new SqlConnection();
  4. con.ConnectionString = "Data Source=LEGEND-DG31PR\\usmansql;Initial Catalog=Biztek;Integrated Security=True";
  5. con.Open();
  6.  
  7. SqlCommand com = new SqlCommand();
  8. com.CommandType = CommandType.StoredProcedure;
  9. com.CommandText = "sp_LoginUser";
  10. com.Connection = con;
  11.  
  12. com.Parameters.Add(new SqlParameter("@username", TextBox1.Text));
  13. com.Parameters.Add(new SqlParameter("@pass", TextBox2.Text));
  14.  
  15.  
  16. SqlDataAdapter adp = new SqlDataAdapter();
  17. adp.SelectCommand = com;
  18.  
  19.  
  20. DataSet ds = new DataSet();
  21. adp.Fill(ds);
  22.  
  23. if (ds.Tables[0].Rows.Count > 0)
  24. {
  25. GridView1.DataSource = ds.Tables[0];
  26. GridView1.DataBind();
  27. }
  28. }
  29.  
  30. catch
  31. {
  32. Label3.Text = "Try Again";
  33. }
Add Comment
Please, Sign In to add comment