using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.VisualBasic; using System.Data; using System.Configuration; using System.Collections; using System.Data.SqlClient; namespace Database3 { public class StudentDataTier { static String connString = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString; static SqlConnection myConn = new SqlConnection(connString); static System.Data.SqlClient.SqlCommand cmdString = new System.Data.SqlClient.SqlCommand(); public DataSet GetStudents(string studid, string lname, DateTime dob) { try { // open connection myConn.Open(); //clear any parameters cmdString.Parameters.Clear(); // command cmdString.Connection = myConn; cmdString.CommandType = CommandType.StoredProcedure; cmdString.CommandTimeout = 1500; cmdString.CommandText = "SearchStudent"; // Define input parameter cmdString.Parameters.Add("@studentid", SqlDbType.VarChar, 6).Value = studid; cmdString.Parameters.Add("@lname", SqlDbType.VarChar, 25).Value = lname; cmdString.Parameters.Add("@dob", SqlDbType.Date).Value = dob; // adapter and dataset SqlDataAdapter aAdapter = new SqlDataAdapter(); aAdapter.SelectCommand = cmdString; DataSet aDataSet = new DataSet(); // fill adapter aAdapter.Fill(aDataSet); // return dataSet return aDataSet; } catch (Exception ex) { throw new ArgumentException(ex.Message); } finally { myConn.Close(); } } } }