Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Read data from table ... ado.net

Posted on 2014-10-22
3
Medium Priority
?
243 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 64

Accepted Solution

by:
Fernando Soto earned 2000 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 64

Expert Comment

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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 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