?
Solved

Sql - fill textboxes

Posted on 2006-04-14
2
Medium Priority
?
254 Views
Last Modified: 2010-04-23
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.
0
Comment
Question by:VBdotnet2005
  • 2
2 Comments
 
LVL 2

Accepted Solution

by:
af4643 earned 1500 total points
ID: 16458969
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
con.open
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.close

con = nothing
0
 
LVL 2

Expert Comment

by:af4643
ID: 16520769
thanks for the accept, but why do I get just a "B" grade?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question