Solved

DataSet Madness

Posted on 2011-09-28
8
207 Views
Last Modified: 2012-05-12
I am having a bit of a brain fart on this.  I have a table that is returned as a dataset \ datatable.  

The table is laid out like this.

Type     sysid                   DESCRIPTION
0           BLANK                BLANK      
1          OnlineTkt              Online Ticket
2          InstantTkt              Instant Ticket
4          Discount              Discount
5         Merchandise        Merchandise
6         PartnerPlay              Partner Play
7        DoubleTripler             Doubler/Tripler
9        2ndChance             Second Chance

I would expect this code to return the value dt.Rows(4)("Description") Discount, but instead return Merchandise.  Is there away I can look at this based on the Type Column versus Row number?  In other words Select Description where TYPE = x  ( which should is 4 )
0
Comment
Question by:mddohm
  • 4
  • 3
8 Comments
 
LVL 1

Expert Comment

by:razza_b
ID: 36716124
try dt.Rows(3) ??
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36716137
You can use datatable select method
YourDataTable.Select("Type = 4"); which returns array of DataRow
0
 

Author Comment

by:mddohm
ID: 36716149
How do I get the value of the description column?
x = 4
dt.Select("Type = " & x)("Description")
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36716154
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36716163
Something like this

    foundRows = Your_data_table.Select("Type = " & x)

    Dim i As Integer
   
    For i = 0 to foundRows.GetUpperBound(0)
       Console.WriteLine(foundRows(i)("Description"))
    Next i
0
 

Author Comment

by:mddohm
ID: 36716186
x = 4

dt.Select("Type = " & x.GetUpperBound(0).ToString() does not work....

The select will narrow this down to one row, is there an easier way to get the value of the Description column?  I need to send the datatable to another Call
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 500 total points
ID: 36716203
You are doing wrong.

x = 4
Dim foundRows() As DataRow
foundRows = dt.Select("Type = " & x)
Dim your_description As String
your_description = foundRows(0)("Description")
0
 

Author Closing Comment

by:mddohm
ID: 36716243
Thanks for bearing with me.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

21 Experts available now in Live!

Get 1:1 Help Now