4
Answers

Displaying ONLY the latest number...

Israel

Israel

8y
413
1
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)