目前,我哈 private void btnInsertStudentNumberAdmin_Click(object sender,EventArgs e) {
这是我的 MySqlConnection conn = connection(); conn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.tAverage“,studentInsert); prevID(conn,cmd); }
答案 0 :(得分:1)
您需要更改方法接受其他参数
public static void insertStudent(string personID, string studentNumber,string gradePointAverage , string majorFieldt)
请注意,您需要根据您为相关参数提供n数据库的列数据类型提供正确的类型。例如,如果personID在数据库中是整数,则应将参数更改为int personID
使用所有参数更改sql语句
INSERT INTO student(personID, studentNumber, gradePointAverage , majorField ) VALUES (@personID, @studentNumber, @gradePointAverage , @majorField)
并使用
设置参数值cmd.Parameters.AddWithValue("@personID", personID);
cmd.Parameters.AddWithValue("@studentNumber", studentNumber);
cmd.Parameters.AddWithValue("@gradePointAverage", gradePointAverage );
cmd.Parameters.AddWithValue("@majorField", majorField );
您可以按以下方式调用以上方法
private void btnInsertStudentNumberAdmin_Click(object sender, EventArgs e)
{
studentHelperClass.insertStudent(txtInsertStudentNumber.Text, txtstudentNumber.Text, txtgradePointAverage.Text , txtmajorField.Text );
}