Solved

Read data from table ... ado.net

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

Independent Software Vendors: 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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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