C
C#3y 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();
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.'
System.Data.SqlClient.SqlException: 'Column name or number of supplied values does not match table definition.'
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server