Retrieve data from dataset (newbie)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?ISO-8859-1?Q?S=F8ren?=

    Retrieve data from dataset (newbie)

    Hi guys

    I hope this is the correct news group. If not .. then please point me in
    the right direction.

    Ok - to the problem:


    I´ve got a dataset with a table that contains some rows. How to I
    execute a sql statement like this:

    SELECT DISTINCT [ROW] FROM [TABLE] WHERE ...

    ... on the dataset, and write the output to the console?


    Regards Søren
  • Cor Ligthert [MVP]

    #2
    Re: Retrieve data from dataset (newbie)

    Soren,

    You cannot use a Select on a DataSet, however there is since version 2.0 an
    overloaded DataView method which does what you ask.



    Cor

    "Søren" <spammers@die.y oungschreef in bericht
    news:e5bQAcQAJH A.5048@TK2MSFTN GP05.phx.gbl...
    Hi guys
    >
    I hope this is the correct news group. If not .. then please point me in
    the right direction.
    >
    Ok - to the problem:
    >
    >
    I´ve got a dataset with a table that contains some rows. How to I execute
    a sql statement like this:
    >
    SELECT DISTINCT [ROW] FROM [TABLE] WHERE ...
    >
    .. on the dataset, and write the output to the console?
    >
    >
    Regards Søren

    Comment

    • Bill McCarthy

      #3
      Re: Retrieve data from dataset (newbie)

      Hi Søren,

      If you are using VB 2008 you can use LINQ to Dataset, eg.

      Dim customers As DataTable = ds.Tables("Cust omer")

      Dim query = From cust In customers.AsEnu merable() _
      Where cust.Field(Of String)("LastNa me") ="Smith" _
      Select cust Distinct

      Look for "LINQ to Dataset" for more examples.





      "Søren" <spammers@die.y oungwrote in message
      news:e5bQAcQAJH A.5048@TK2MSFTN GP05.phx.gbl...
      Hi guys
      >
      I hope this is the correct news group. If not .. then please point me in
      the right direction.
      >
      Ok - to the problem:
      >
      >
      I´ve got a dataset with a table that contains some rows. How to I execute
      a sql statement like this:
      >
      SELECT DISTINCT [ROW] FROM [TABLE] WHERE ...
      >
      .. on the dataset, and write the output to the console?
      >
      >
      Regards Søren

      Comment

      • =?ISO-8859-1?Q?S=F8ren?=

        #4
        Re: Retrieve data from dataset (newbie)

        Thanks. That was just what I needed. :-)

        Regards Søren


        Bill McCarthy skrev:
        Hi Søren,
        >
        If you are using VB 2008 you can use LINQ to Dataset, eg.
        >
        Dim customers As DataTable = ds.Tables("Cust omer")
        >
        Dim query = From cust In customers.AsEnu merable() _
        Where cust.Field(Of String)("LastNa me") ="Smith" _
        Select cust Distinct
        >
        Look for "LINQ to Dataset" for more examples.
        >
        >
        >
        >
        >
        "Søren" <spammers@die.y oungwrote in message
        news:e5bQAcQAJH A.5048@TK2MSFTN GP05.phx.gbl...
        >Hi guys
        >>
        >I hope this is the correct news group. If not .. then please point me
        >in the right direction.
        >>
        >Ok - to the problem:
        >>
        >>
        >I´ve got a dataset with a table that contains some rows. How to I
        >execute a sql statement like this:
        >>
        >SELECT DISTINCT [ROW] FROM [TABLE] WHERE ...
        >>
        >.. on the dataset, and write the output to the console?
        >>
        >>
        >Regards Søren
        >

        Comment

        Working...