using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; 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; using Database2; namespace Database3 { public partial class frmSearch : Form { public frmSearch() { InitializeComponent(); } private void btnSearch_Click(object sender, EventArgs e) { string studentid = ""; try { DataSet ds = new DataSet(); StudentDataTier stuDT = new StudentDataTier(); studentid = txtStuID.Text.Trim(); //get the dataset ds = stuDT.GetStudents(studentid); // check to see if any record is returned if (ds.Tables[0].Rows.Count > 0) //there is a record { dgvStudents.Visible = true; // get data source dgvStudents.DataSource = ds.Tables[0]; dgvStudents.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGreen; // Set the row and column header styles. dgvStudents.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; dgvStudents.ColumnHeadersDefaultCellStyle.BackColor = Color.Green; } } catch (Exception ex) { // Handle exception } } } }