Hi,
I wrote these codes to display the LAST row ONLY. Then how can I display ONLY the first row from textbox one click.
I wrote these codes to display the LAST row ONLY. Then how can I display ONLY the first row from textbox one click.
C#:
private void button_Click(object sender, EventArgs e)
{
string commandString = "select top 1 * from Test where name='" + txtNumber.Text ";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
txtNumber.Text = read["number"].ToString();
}
}
else
{
MessageBox.Show("Name " + txtName.Text + " not found");
}
read.Close();
sqlCon.Close();
Last edited: