Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Constructor has 2 arguments, but claims it does not have a constructor that takes two arguments
    primarykey
    data
    text
    <p>So here is my problem. I have a class called Login that will be used for logging in and creating new log in accounts.</p> <p>I've created a Login constructor that takes no arguments</p> <pre><code>public Login() { _gloID = 0; _Username = null; _Password = null; _Note = null; _Active = false; _Status = null; _gvoID = 0; _DateModified = new DateTime(1901, 1, 1); _ModifiedBy = 0; } </code></pre> <p>I've also created a Login constructor that takes two arguments. This constructor takes the username and password and then gathers the rest of the information from the database.</p> <pre><code>public Login(string username, string password) { // Declarations uint gloid = 0, gvoid = 0, modifiedby = 0; string note = null, status = null; bool active = false; DateTime datemodified = new DateTime(1901, 1, 1); // Command string query = string.Format("SELECT glo_id, glo_note, glo_active, glo_status, gvo_id, date_modified, modified_by FROM gfrc_login" + " WHERE glo_username = '{0}' AND glo_password = '{1}'", username, password); try { using (conn) { conn.Open(); cmd = new OleDbCommand(query, conn); rdr = cmd.ExecuteReader(); while (rdr.Read()) { gloid = Convert.ToUInt32(rdr.GetString(0)); note = rdr.GetString(1).ToString(); active = Convert.ToBoolean(rdr.GetString(2)); status = rdr.GetString(3).ToString(); gvoid = Convert.ToUInt32(rdr.GetString(4)); datemodified = Convert.ToDateTime(rdr.GetString(5)); modifiedby = Convert.ToUInt32(rdr.GetString(6)); } } } finally { if (rdr != null) rdr.Close(); } if (conn != null) { conn.Close(); } _gloID = gloid; _Username = username; _Password = password; _Note = note; _Active = active; _Status = status; _gvoID = gvoid; _DateModified = datemodified; _ModifiedBy = modifiedby; } </code></pre> <p>Note that all the database connection variables have been declared at the beginning of the class.</p> <p>Now when I try to run the following I get an error saying: 'Login' does not contain a constructor that takes 2 arguments.</p> <pre><code>protected void Login_Authenticate(object sender, EventArgs e) { string username = txtUsername.Text; string password = CalculateMD5(txtPassword.Text); Login login = new Login(username, password); } </code></pre> <p>EDIT: FYI, I have measures preventing SQL injections in the rest of my code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload