public Pre_Requirement getData(string courseName) { string prq1 = "", prq2 = ""; string sn = "SELECT Pre_Requirement_1,Pre_Requirement_2 FROM Curriculum WHERE Course_Name='" + courseName + "'"; SqlCeCommand cmd = new SqlCeCommand(sn, con); SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { prq1 = rdr["Pre_Requirement_1"].ToString(); prq2 = rdr["Pre_Requirement_2"].ToString(); } con.Close(); Pre_Requirement pq = new Pre_Requirement(prq1, prq2); return(pq); }
private void metroButton1_Click(object sender, EventArgs e) { DatabaseAccess db = new DatabaseAccess(); string courseName, prq1 = "", prq2 = ""; courseName = textBox1.Text; Pre_Requirement pq = db.getData(courseName); prq1 = pq.PreReq_1; prq2 = pq.PreReq_2; listBox1.DataSource = null; if (prq1 != null) { listBox1.Items.Add(prq1); } if (prq2 != null) { listBox1.Items.Add(prq2); } }