Solved

Read data from table ... ado.net

Posted on 2014-10-22
3
211 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 62

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 33

Author Comment

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

Expert Comment

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

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

13 Experts available now in Live!

Get 1:1 Help Now