diff --git a/Database3/StudentDataTier.cs b/Database3/StudentDataTier.cs index 536a929..0441c17 100644 --- a/Database3/StudentDataTier.cs +++ b/Database3/StudentDataTier.cs @@ -18,7 +18,7 @@ namespace Database3 static SqlConnection myConn = new SqlConnection(connString); static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand(); - public DataSet GetStudents(string studid, string lname, string dob) + public DataSet GetStudents(string studid, string lname, DateTime dob) { try { diff --git a/Database3/frmSearch.cs b/Database3/frmSearch.cs index ac604ed..f5287fc 100644 --- a/Database3/frmSearch.cs +++ b/Database3/frmSearch.cs @@ -33,24 +33,33 @@ namespace Database3 { string studentid = "9999999999"; string lname = "9999999999"; - string dob = null; + DateTime dob = new DateTime(1/1/1111); + + ErrorProvider ep1 = new ErrorProvider(); try { DataSet ds = new DataSet(); StudentDataTier stuDT = new StudentDataTier(); - try - { studentid = txtStuID.Text; lname = txtlname.Text; - dob = txtDOB.Text; + try + { + dob = DateTime.Parse(txtDOB.Text); } catch (Exception exception) { - MessageBox.Show("Error Parsing Search Parameters","Error", MessageBoxButtons.OK); + ep1.SetError(txtDOB, "Non valid value, but that's ok"); + } + + if (string.IsNullOrWhiteSpace(txtStuID.Text) && + string.IsNullOrWhiteSpace(txtlname.Text) && + string.IsNullOrWhiteSpace(txtDOB.Text)) + { + throw new Exception("Must Enter at least one value"); } // Get the dataset using all three search parameters.