MySqlConnection cnn = new MySqlConnection(mysqladdress);
cnn.Open();
MessageBox.Show("Registered!");
MySqlCommand cmdinsert;
try
{
cmdinsert = cnn.CreateCommand();
cmdinsert.CommandText = "Insert into student(Name,Age,School,StudentID,Username,Password) values (@Name,@Age,@School,@StudentID,@Username,@Password)";
cmdinsert.Parameters.AddWithValue("@Name", textBox1.Text.ToString());
cmdinsert.Parameters.AddWithValue("@Age", textBox2.Text.ToString());
cmdinsert.Parameters.AddWithValue("@School", textBox3.Text.ToString());
cmdinsert.Parameters.AddWithValue("@StudentID", textBox5.Text.ToString());
cmdinsert.Parameters.AddWithValue("@Username", textBox6.Text.ToString());
cmdinsert.Parameters.AddWithValue("@Password", textBox7.Text.ToString());
cmdinsert.ExecuteNonQuery();
}
catch (Exception)
{
throw;
}
finally
{
if (cnn.State == ConnectionState.Open)
{
cnn.Close();
datagridviewfunction();
}
}
**总是有错误说:"未知列' StudentID'在'字段列表'" 问题出在" throw" 该怎么办?请帮助我,以便我可以转到下一个表格**