匹配值計數我不知道爲什麼我收到此錯誤:列數確實在第1行C#
C#代碼:
using (MySqlConnection connection = new MySqlConnection("datasource=localhost;port=3306;database=project;username=***;password=***;"))
{
MySqlCommand cmd = new MySqlCommand("INSERT INTO student (studentID, studentFirstName, studentLastName, studentUserName, studentPassword) VALUES (@userID, @, @FirstName, @LastName, @Username, @Password);");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("userID", Convert.ToInt32(textBoxUserID.Text));
cmd.Parameters.AddWithValue("@FirstName", textBoxFirstName.Text);
cmd.Parameters.AddWithValue("@LastName", textBoxLastName.Text);
cmd.Parameters.AddWithValue("@UserName", textBoxUsername.Text);
cmd.Parameters.AddWithValue("@Password", textBoxPassword.Text);
connection.Open();
cmd.Connection = connection;
cmd.ExecuteNonQuery();
MessageBox.Show("Saved");
connection.Close();
}
這可能是由於我忽視的東西。
錯誤:
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data
Additional information: Column count doesn't match value count at row 1
其漂亮的自我解釋..你要我勺子你的一切飼料.. – CSEngine
錯誤消息是返回是相當自我解釋。不,我不希望你做任何事情。 http://stackoverflow.com/questions/16704328/c-sharp-mysql-error-column-count-doesnt-match-value-count-at-row-1 – spencer7593