Visual Studio 2008 (Visual Basic OR C#) -- Lookup Table w/ TextBoxes

Hi Experts!  <Visual Basic 2008 Newbie here> !

I want to create a very simple (1 page VB2008 form), which connects to an external table, "looks up" values based on a Zip Code ... and populates three(3) textboxes on my form.  Note:  I purchased a TABLE (ZipInfo) from a commercial carrier, which is ALREADY POPULATED with every valid zipcode, city, state and county in the country.

So.. to begin:
1)  I want to create a VB 2008 Form, which will have only four (4) text boxes, labeled as follows: txtZipcode,  txtCity,   txtState,   and   txtCounty.  

2)  I want the user to enter in a 'Zip Code' in the textbox labeled:   'txtZipcode'.  After the
     user presses 'ENTER',

3)  I want my VB2008 form to then execute some code (???) which will:
     a) lookup the matching city, state and county field values, from the Zipcode (ZipInfo) table;
     b) populate each of the three textboxes (labeled txtCity, txtState, txtCounty) on my
         VB2008 form, with the corresponding information from the Zipcode table.

I have ATTACHED a picture of the VB2008 form, I've created so far.

I don't know anything, other then to drag the textboxes from the VB2008  toolbox to a blank form.  I don't understand ADO, or coding or where to put the code to begin with.  I don't know how to reference the connection to the ZipInfo table.  I'm not even certain how to connect properly to the data source.

When I asked this question before, I was given a VB 6 solution, which doesn't appear to work with VB 2008.  

I would really like to know a VB2008 solution and a C# solution, ideally ... so that I can try and understand how making data connections, connecting to the data and populating forms works in Visual Studio 2008.

In conclusion,

I need a 'STEP-BY-STEP' answer, so that I can learn easily.  I'm guessing that there are likely many blog readers who would benefit by your answer(s).

Thanks Everyone!


VB2008-Form.jpg
DelphiNewbAsked:
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.

guru_samiCommented:
what database would be that table in?
here is are some basic tutorials on using Ado.net with C#:
http://asp.dotnetheaven.com/howto/doc/adoplus/sqldtreader.aspx
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx
0
DelphiNewbAuthor Commented:
Hello Guru_Sami --

Thank you very much Guru_Sami for the tutorial links... I am studying them now...

To answer your question, the database I was considering was either SQL Server Express 2008, or...
VistaDB.

Thank you again for the information ... this might provide me enough information.  Reviewing now.

If you come across any additional information, I would appreciate it. --- Thomas
0
CodeCruiserCommented:
Here is some example code in VB.NET.
Private Sub txtZipCode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtZipCode.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Dim dbcon As New SqlConnection(connectionstring)
            dbcon.Open()
            Dim dbcmd As New SqlCommand
            dbcmd.Connection = dbcon
            dbcmd.CommandText = "Select City, State, County from tblAddresses where zipcode=" & txtZipCode.Text
            Dim dbreader As SqlDataReader = dbcmd.ExecuteReader
            If dbreader.HasRows Then
                dbreader.Read()
                txtCity.Text = dbreader.Item("City")
                txtState.Text = dbreader.Item("State")
                txtCounty.Text = dbreader.Item("County")
            End If
            dbreader.Close()
            dbcmd.Dispose()
            dbcon.Dispose()
        End If
    End Sub

Open in new window

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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

DelphiNewbAuthor Commented:
I want to thank CodeCruiser very much ... your example was right on, and will work great!
Thank you so much for your clear and complete answer!

CodeCruiser ... you rock!

Thanks --- DelphiNewb
0
DelphiNewbAuthor Commented:
CodeCruiser's answer was very very helpful.

I am now his or her (CodeCruiser's) fan!
0
CodeCruiserCommented:
Glad to help :-)
0
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
.NET Programming

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.