Advertisement
Guest User

help coding runescape

a guest
Jun 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data.SqlClient;
  6. using System.Configuration;
  7. using System.Web.UI.WebControls;
  8.  
  9. /// <summary>
  10. /// Summary description for AccountDetails
  11. /// </summary>
  12. public class AccountDetails
  13. {
  14. string _connStr = ConfigurationManager.ConnectionStrings["CreateAccount"].ConnectionString;
  15. private string _UserName;
  16. private string _Password;
  17. private string _Dob;
  18. private string _Email;
  19. private string _Gender;
  20.  
  21.  
  22. public AccountDetails()
  23. {
  24.  
  25. }
  26. //overloaded class constructor with 4 parameters
  27. public AccountDetails(string p_UserName, string p_Password, string p_Dob, string p_Gender, string p_Email)
  28. {
  29. this.UserName = p_UserName;
  30. this.Password = p_Password;
  31. this.Dob = p_Dob;
  32. this.Gender = p_Gender;
  33. this.Email = p_Email;
  34. }
  35.  
  36.  
  37.  
  38. public int CreateAccount()
  39. {
  40. string msg = null;
  41. int result = 0;
  42. string queryStr = "INSERT INTO Accountdetails(Username,Password,Dob,Gender,Email)"
  43. + "values (@UserName,@Password,@Dob , @Gender, @Email)";
  44.  
  45. SqlConnection conn = new SqlConnection(_connStr);
  46.  
  47. SqlCommand cmd = new SqlCommand(queryStr, conn);
  48.  
  49. cmd.Parameters.AddWithValue("@UserName", this.UserName);
  50. cmd.Parameters.AddWithValue("@Password", this.Password);
  51. cmd.Parameters.AddWithValue("@Dob", this.Dob);
  52. cmd.Parameters.AddWithValue("@Gender", this.Gender);
  53. cmd.Parameters.AddWithValue("@Email", this.Email);
  54. conn.Open();
  55. result += cmd.ExecuteNonQuery(); // Returns no. of rows affected. Must be > 0
  56. conn.Close();
  57. return result;
  58.  
  59. }
  60.  
  61.  
  62.  
  63.  
  64. //public class properties, accessing from outside the class is possible
  65. public string UserName
  66. {
  67. get { return _UserName; }
  68. set { _UserName = value; }
  69. }
  70. public string Password
  71. {
  72. get { return _Password; }
  73. set { _Password = value; }
  74. }
  75. public string Dob
  76. {
  77. get { return _Dob; }
  78. set { _Dob = value; }
  79. }
  80. public string Gender
  81. {
  82. get { return _Gender; }
  83. set { _Gender = value; }
  84. }
  85. public string Email
  86. {
  87. get { return _Email; }
  88. set { _Email = value; }
  89. }
  90. }
  91.  
  92.  
  93. this is the code im using
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement