Israel

Israel

  • 703
  • 1.3k
  • 215.5k

forced to display the very last record after search...

Oct 20 2015 5:39 AM
Hi!
 
Please I need urgently to display the very last record after search. I try this code but its doesnt do it.
I know that with this line of code for example its works: dvgTest.CurrentCell = dvgTest.Rows[dvgTest.Rows.Count - 1].Cells[0]; 
But works only with datagrid. Then how can I make it work after my search:
 
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Visa\App_Data\visa.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from bill where company='" + cbxMention2.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
txtMention21.Text = read["code"].ToString();
}
}
else
{
MessageBox.Show("This code " + txtMention21.Text + " doesnt exist");
}
read.Close();
sqlCon.Close();
 
 

Answers (2)