Advertisement
Guest User

Untitled

a guest
Sep 14th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public int testCon()
  2. {
  3. using (SqlConnection conn = new SqlConnection("Conn string"))
  4. {
  5. using (SqlCommand cmd = conn.CreateCommand())
  6. {
  7. conn.Open();
  8. cmd.CommandText = "SELECT COUNT(1) FROM Carsd";
  9.  
  10. return (int)cmd.ExecuteScalar();
  11. }
  12. }
  13. }
  14.  
  15. class Program
  16. {
  17. static void Main(string[] args)
  18. {
  19. testDispose objTestDispose;
  20.  
  21. using (objTestDispose = new testDispose())
  22. {
  23. objTestDispose.UserName = "testUser";
  24. objTestDispose.PassWord = "testPassword";
  25. }
  26.  
  27. Console.WriteLine("Check obj of testDispose Class" + objTestDispose.UserName);
  28. Console.WriteLine("Check obj of testDispose Class" + objTestDispose.PassWord);
  29. Console.ReadLine();
  30.  
  31. }
  32. }
  33.  
  34. public class testDispose : IDisposable
  35. {
  36. public string UserName { get; set; }
  37. public string PassWord { get; set; }
  38.  
  39. public void Dispose()
  40. { }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement