0
votes

Currently, I ha private void btnInsertStudentNumberAdmin_Click(object sender, EventArgs e) {

and this is my m MySqlConnection conn = connection(); conn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.tAverage", studentInsert); prevID(conn, cmd); }

1

1 Answers

1
votes

you need to change the method accept additional parameters

public static void insertStudent(string personID, string  studentNumber,string  gradePointAverage , string majorFieldt)

Note that you need to give correct type based on column data type you given n database for related parameter. for example if personID is integer in database you should change parameter as int personID

change your sql statement with all the parameters

INSERT INTO student(personID, studentNumber, gradePointAverage , majorField ) VALUES (@personID, @studentNumber, @gradePointAverage , @majorField)

and set the parameter values using

cmd.Parameters.AddWithValue("@personID", personID);
cmd.Parameters.AddWithValue("@studentNumber", studentNumber);
cmd.Parameters.AddWithValue("@gradePointAverage", gradePointAverage );
cmd.Parameters.AddWithValue("@majorField", majorField );

you can call above method as below

private void btnInsertStudentNumberAdmin_Click(object sender, EventArgs e)
{
  studentHelperClass.insertStudent(txtInsertStudentNumber.Text, txtstudentNumber.Text, txtgradePointAverage.Text , txtmajorField.Text );
}