Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read data from table ... ado.net

Posted on 2014-10-22
3
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 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