Solved

DataSet Madness

Posted on 2011-09-28
8
210 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
[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
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36716154
0
 
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I do Unit Testing with Session ? 1 23
WPF user control poped up from a window 1 35
asp.net web app 3 27
Need help for captcha 2 22
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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