Load Record by value in textbox

I need to be able to load a record into muliple textboxes by entering a value into one of the textboxes.

How can I do this?
LVL 1
Andrew StillwellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

YurichCommented:
i think you have to be more detailed on this...

1. load a record from where?? - a data base or flat file or dataset or xml or what??
2. do you want to enter a value, press button and trigger the event, or you want start typing and as soon as something is typed, you want to trigger your event, or you want to type something as soon as focus leaves the textobx, you want to trigger your event.

regs,
yurich

0
Andrew StillwellAuthor Commented:
1. load a record from where?? - a data base or flat file or dataset or xml or what??

From an Access database

2. do you want to enter a value, press button and trigger the event, or you want start typing and as soon as something is typed, you want to trigger your event, or you want to type something as soon as focus leaves the textobx, you want to trigger your event.

As soon as a value is entered I want it to retrieve the values for each textbox
0
YurichCommented:
there're really several approaches, one of them:

suggesting that you want to do it in the OnButton_Click method of the button after all data is entered in all texboxes.

// add this directive to all using directive
using System.Data.OleDbClient;
...

// that's in your button handling event
OleDbConnection conn = new OleDbConnection();
// connection string can of course be different
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb";
conn.Open();

OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM table_name WHERE something = '" + txtCriterion.Text + "'";
OleDbDataReader dreader = cmd.ExecuteReader();

if( dreader.Read())
{
  txtValue1.Text = dreader[ "column_name1" ].ToString();
  txtValue2.Text = dreader[ "column_name2" ].ToString();
}

dreader.Close();
conn.Close();

it should give you a go,
good luck,
yurich
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.