C#C
C#4y ago
koopa

SQL Error when trying to get an ID

I'm trying to add username password and email to my users table
And then get the ID of this new user.
            SqlCommand cmd = new SqlCommand("insert into Users values(@username,@password,@email)", cn);
            cmd.Parameters.AddWithValue("username", info["username"]);
            cmd.Parameters.AddWithValue("password", encryptedPW);
            cmd.Parameters.AddWithValue("email", info["email"]);
            int id = (int)cmd.ExecuteScalar();

however I get this error:

System.Data.SqlClient.SqlException: 'Column name or number of supplied values does not match table definition.'
Was this page helpful?