Israel

Israel

  • 699
  • 1.3k
  • 217.5k

Displaying ONLY the latest number...

Apr 2 2016 7:47 AM
Hi!
 
I wrote these codes I would like to know how can I show the latest number on my textbox by order's number after doing my search.
I need to inform that these codes work well but the only thing I am asking is to show me how can I display on my textbox ONLY the latest number concerning my search by order's number.
Here is my codes:
 
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\LunaVisa\Visa\Visa\App_Data\visa.mdb;Persist Security Info=False";
 
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from company where name='" + txtName.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
txtShowLastNumber.Text = read["Number"].ToString(); 
}
}
else
{
MessageBox.Show("The last number" + txtName.Text + " wasnt be found");
}
read.Close();
sqlCon.Close();
 

Answers (4)