i got this piece of code i need someone to do a minor modification for me. Its from searching a datagrid and i need a message box to appear when the record is not found:
private void btnSearch_Click(object sender, System.EventArgs e)
{
// Verify that the user typed test to search for.
if(txtSearch.Text == "")
{
MessageBox.Show("Enter some criteria to find.");
txtSearch.Focus();
}
else
{
// Create a SqlCommand
OleDbCommand oleDbSelectCommand1 = oleDbConnection1.CreateCommand();
oleDbSelectCommand1.CommandType = CommandType.Text;
oleDbSelectCommand1.CommandText = "SELECT * FROM Students";
// Use the Select method to get a **sorted** array of DataRows
{
DataRow[] adr = ds.Tables["Students"].Select(
"FirstName = '" + txtSearch.Text + "'","");
// Dump the result to the user interface
lbStudents.Items.Clear();
foreach(DataRow dr in adr)
{
//******************FORMATTING LISTBOX***********
////////////////////////////////////////////////
////////////////////////////////////////////////
lbStudents.Items.Add("");
lbStudents.Items.Add("Student ID : " + dr[5]);
lbStudents.Items.Add("First Name : " + dr[3]);
lbStudents.Items.Add("Last Name : " + dr[1]);
lbStudents.Items.Add("Address : " + dr[0]);
lbStudents.Items.Add("Phone : " + dr[4]);
lbStudents.Items.Add("GPA : " + dr[2]);
lbStudents.Items.Add("");
////////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
}
}
thnx