AccessDataSource Select Command

Discussion in 'ASP .Net' started by Jim McGivney, Apr 16, 2006.

  1. Jim McGivney

    Jim McGivney Guest

    In VS'05 I have an aspx page with a label that I am trying to populate from
    a field (Last) in table (Ante_Pedigree) from an Access database.

    In C# in a code-behind I run:

    AccessDataSource AccessDataSource2 = new AccessDataSource();
    AccessDataSource2.DataFile =
    System.Configuration.ConfigurationManager.AppSettings["ConnString"];
    Parameter Param = new Parameter("AnteNum");
    Param.DefaultValue = fileid;
    AccessDataSource2.SelectParameters.Add(Param);
    AccessDataSource2.SelectCommand = "SELECT Last FROM Ante_Pedigree Where
    AnteNum=@Param";
    LabelFileNum.Text =
    AccessDataSource2.Select(DataSourceSelectArguments.Empty).ToString();



    The result is that LabelFileNum.Text = System.Data.DataView

    What am I doing wrong; I am obviously using an advanced feature when all I
    want to do is retrieve a value.

    Thanks in advance for your help.

    Jim
     
    Jim McGivney, Apr 16, 2006
    #1
    1. Advertising

  2. Jim McGivney

    Neutrino Guest

    The ToString() method is returning System.Data.DataView because that is
    the type of the object returned by the Select member of
    AccessDataSource .

    You may need to cast to a DataView to then retrieve the record you
    need:

    LabelFileNum.Text =
    ((DataView)AccessDataSource2.Select(DataSourceSelectArguments.Empty))[0]["Last"].ToString();

    Hope this helps.
     
    Neutrino, Apr 17, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. podong28
    Replies:
    1
    Views:
    516
    Brock Allen
    Apr 19, 2005
  2. msnews.microsoft.com

    GridView/AccessDataSource update

    msnews.microsoft.com, Jul 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,337
    msnews.microsoft.com
    Jul 19, 2005
  3. nicholas
    Replies:
    1
    Views:
    1,449
  4. =?Utf-8?B?QWxlc3NhbmRybw==?=

    AccessDataSource, help please;.

    =?Utf-8?B?QWxlc3NhbmRybw==?=, Jan 16, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    386
    =?Utf-8?B?QWxlc3NhbmRybw==?=
    Jan 16, 2006
  5. palmiere
    Replies:
    1
    Views:
    474
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page