所以我有一个辅助类,其中包含以下代码:
public static DataSet selectStudent()
{
MySqlConnection conn = connection();
conn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
MySqlDataAdapter adap = new MySqlDataAdapter(@"SELECT * FROM student", conn);
MySqlCommandBuilder sqlCmd = new MySqlCommandBuilder(adap);
DataSet sqlSet = new DataSet();
adap.Fill (sqlSet, "studentInfo");
conn.Close();
return sqlSet;
}
在我的表单中,我有一个显示学生数据的按钮,代码如下:
private void btnStudentView_Click(object sender, EventArgs e)
{
DataSet ds = studentHelperClass.selectStudent();
lsbBoxStudent.DataSource = ds.Tables["studentInfo"];
lsbBoxStudent.DisplayMember = "studentNumber";
}
但是,这仅显示studentNumber
表格的行,我还需要它来显示这些majorField
和gradePointAverage
.
我该怎么做呢?