Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fredrik Esseen 610 posts 906 karma points
    Dec 14, 2010 @ 14:26
    Fredrik Esseen
    0

    Get Single record with IRecordsReader

    Probably a simple question but how do I get a single record with IRecordsReader?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Dec 14, 2010 @ 18:54
    Lee Kelleher
    0

    Hi froad,

    Do you have an example snippet of code - to give more context of what you are trying to achieve?

    You should be able to call .Read() on the IRecordsReader (or implemented object rather) - then call GetValue (or whatever relevant "Get" method) on the first row.

    Cheers, Lee.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Dec 14, 2010 @ 23:01
    Aaron Powell
    1

    Yes it's possible, but I strongly suggest you go with a real ORM like LINQ to SQL, Entity Framework 4, NHibernate, etc.

  • Fredrik Esseen 610 posts 906 karma points
    Dec 15, 2010 @ 08:34
    Fredrik Esseen
    0

    As usual I was too fast asking on this forum :)

    I didnt think I could use the simple Read() but so was the case:

    if

     

    (reader.HasRecords)

    {

    reader.Read();

    Label.Text = reader.GetInt(

    "Count").ToString();

    }

    I really have to start looking at LINQ! Just have to find the time..

    Thx for your time :)

Please Sign in or register to post replies

Write your reply to:

Draft