Click here to Skip to main content
15,435,848 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
select * from receptiondatabase where personid='k78930'// Passport no
The person visited multilple times in a day. Hence the database giving multiple rows.

The language is C#
I have a textbox to type the passport number. The data is retrieving using sqldatareader which is showing in the other text boxes (name, purpose of visit) only for one row.
How to show the other transactions in textboxes when pressing down arrow key?

What I have tried:

if (reader.HasRows)
{
while (reader.Read())
{
txtname.Text = reader["per_name"].ToString();
txtpurpose.Text = reader["Purpose"].ToString()
}
}
Posted
Updated 23-Jul-22 22:42pm
Comments
Gerry Schmitz 23-Jul-22 11:25am    
How many records are we talking about? Show them in a list type control if it's only a few. Otherwise, you need to run asynch queries using a concurrent queue that your keypress event can reference.

1 solution

You can't.
Windows doesn't work like that: the display will not be updated until your method has exited, so only the final value shown in your textbox will ever be displayed. Windows isn't like console apps: it doesn't sit there and wait for user input, it reacts to user input when it occurs.

As I said when you asked this an hour ago: Call a function/method while pressing tab key .[^]
Quote:
Why the heck would you want to do that?
You want to show / select one by one, use a combo box or similar ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900