Get item from dataset with same column name

Posted on 2007-10-01
Last Modified: 2013-11-26

If i have a sql query that returns a datsset that looks like this

C1 C2 C3 C4 C4

how do i get the C4 when there are two columns with same name

For Each Row In ds.Tables(0).Rows
   strC1 = Row("C1").ToString
   strC2 = Row("C2").ToString
    strC3 = Row("C3").ToString
   strC4_1 = Row(" ???").ToString
    strC4_2 = Row(" ???").ToString
Question by:AWestEng
    LVL 48

    Accepted Solution

    Use the value instead of the name
    strC4_1 = Row(3).ToString
    LVL 1

    Author Comment

    ok, so i can't use the name then.
    LVL 48

    Expert Comment

    If you have the same name I don't know. You can maybe try C4_1 (not shure)
    LVL 1

    Author Comment

    or is it possible to change the name on one og the columns when getting the data from the mysql server .
    why they have the same name is because it's a join statment from two tables
    LVL 48

    Expert Comment

    >> is it possible to change the name on one og the columns
    Yes, you can do:

    SELECT C1,C2,C3,C4,C4 As MyColumn WHERE ...

    Then use:
    strC4_1 = Row("MyColumn").ToString

    Thanks for the grade.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    760 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

    11 Experts available now in Live!

    Get 1:1 Help Now