Sql - fill textboxes

Posted on 2006-04-14
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.
Question by:VBdotnet2005
    LVL 2

    Accepted Solution

    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 '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
    LVL 2

    Expert Comment

    thanks for the accept, but why do I get just a "B" grade?

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now