Solved

Read data from table ... ado.net

Posted on 2014-10-22
3
219 Views
Last Modified: 2014-10-22
Question: What is the correct syntax to read data from a data table?

The right side of the = sign is not working.

              With SQL.ds.Tables(0)
                    Me.CustomerIDTextBox.Text = .Columns.Item("CustomerID")
                    Me.FirstNameTextBox.Text = .Rows(0).Item("FirstName")
                    Me.LastNameTextBox.Text = .Rows(0).Item("LastName")
                    Me.AddressTextBox.Text = .Rows(0).Item("Address")
                    Me.CityTextBox.Text = .Rows(0).Item("City")
                    Me.StateTextBox.Text = .Rows(0).Item("State")
                    Me.ZipCodeTextBox.Text = .Rows(0).Item("ZipCode")
                    Me.EmailTextBox.Text = .Rows(0).Item("Email")
                    Me.PhoneTextBox.Text = .Rows(0).Item("Phone")
                End With

Open in new window

0
Comment
Question by:Mike Eghtebas
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40398536
Hi  eghtebas;

Try it like this to see if you get what you are looking for.

With SQL.ds.Tables(0)
    '' This next line will get the column name.
    Me.CustomerIDTextBox.Text = .Columns("CustomerID").ColumnName
    Me.FirstNameTextBox.Text = .Rows(0)("FirstName")
    Me.LastNameTextBox.Text = .Rows(0)("LastName")
    Me.AddressTextBox.Text = .Rows(0)("Address")
    Me.CityTextBox.Text = .Rows(0)("City")
    Me.StateTextBox.Text = .Rows(0)("State")
    Me.ZipCodeTextBox.Text = .Rows(0)("ZipCode")
    Me.EmailTextBox.Text = .Rows(0)("Email")
    Me.PhoneTextBox.Text = .Rows(0)("Phone")
End With

Open in new window

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40398543
Thanks.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40398553
Not a problem, glad to help.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

837 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