Solved

DataSet Madness

Posted on 2011-09-28
8
206 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

22 Experts available now in Live!

Get 1:1 Help Now