Skip to content

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

Israel

Asked Oct 20, 2015, 1:39 AM EDT2 answers
Share
LinkedInX
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:
 
Java
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();
 

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Please I need your help. I am really stuck.
    0
  • 0
    See what I try to do. But its still doesnt display me the last record:
     
    string commandString = "SELECT * FROM bill WHERE ID = (SELECT MAX(ID) FROM bill ) where company='" + cbxMention2.Text + "'";
    0