Sql - fill textboxes

I have four textboxes : txtClientId, txtAccountNumber, txtPhoneNum, txtFormNum.
I want to retrieve info. from my SQL database and and fill these textboxes. I want a user to enter ClientId, sample, "S14523", and click a btnGet, to retreived info. A link to similiar sample is fine.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Create a stored procedure that accepts the parameter for the ClientID that returns the 4 values.

In your btnGet_Click sub:
Dim con as sqlconnection = new sqlconnection("[connection string]")
Dim cmd as sqlcommand = new sqlcommand("[stored procedure]", con)
Dim reader as sqldatareader

cmd.commandtype = commandtype.storedprocedure
cmd.parameters.add("@clientid", clientid.text) 'clientid is a text box, and @clientid is the parameter name in your stored procedure
reader = cmd.executereader

reader.read 'this is assuming you'll have only 1 row returning. if there's many, then you'll need to loop this

txtClientID.text = reader("txtClientID")                         'column name is in quotes
txtAccountNumber.text = reader("txtAccountNumber")  'column name is in quotes
txtPhoneNum.text = reader("txtPhoneNum")              'column name is in quotes
txtFormNum.text = reader("txtFormNum")          'column name is in quotes


con = nothing

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
thanks for the accept, but why do I get just a "B" grade?
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
Visual Basic.NET

From novice to tech pro — start learning today.