Get record count from filtered datasourse (not set)

Discussion in 'ASP .Net' started by =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Jul 6, 2007.

  1. What are the steps necessary to get the filtered count from datasource. If i
    have to move it into a table just to gat the count i'll do so, but i'm not
    sure what the steps are needed to accomplish this.

    Thanks
    KES
    --
    thanks (as always)
    some day i''m gona pay this forum back for all the help i''m getting
    kes
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Jul 6, 2007
    #1
    1. Advertising

  2. "WebBuilder451" <> wrote in message
    news:...

    > What are the steps necessary to get the filtered count from datasource. If
    > i
    > have to move it into a table just to gat the count i'll do so, but i'm not
    > sure what the steps are needed to accomplish this.


    DataSet MyDS = <fetch DataSet>;
    MyDS.Tables[0].DefaultView.RowFilter = "......";
    int FilterCount = MyDS.Tables[0].DefaultView.Count;


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 6, 2007
    #2
    1. Advertising

  3. thanks for replying,
    I did see this (your answer specific) in another of your postings and it is
    what prompted me to repost with the "(not set)". My admitted lack of
    knowledge here is how to get my dataSOURCE in to the dataSET. (...<fetch
    DataSet>;)

    --
    thanks (as always)
    some day i''m gona pay this forum back for all the help i''m getting
    kes


    "Mark Rae [MVP]" wrote:

    > "WebBuilder451" <> wrote in message
    > news:...
    >
    > > What are the steps necessary to get the filtered count from datasource. If
    > > i
    > > have to move it into a table just to gat the count i'll do so, but i'm not
    > > sure what the steps are needed to accomplish this.

    >
    > DataSet MyDS = <fetch DataSet>;
    > MyDS.Tables[0].DefaultView.RowFilter = "......";
    > int FilterCount = MyDS.Tables[0].DefaultView.Count;
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, Jul 6, 2007
    #3
  4. "WebBuilder451" <> wrote in message
    news:...

    > thanks for replying,
    > I did see this (your answer specific) in another of your postings and it
    > is
    > what prompted me to repost with the "(not set)". My admitted lack of
    > knowledge here is how to get my dataSOURCE in to the dataSET. (...<fetch
    > DataSet>;)


    You need to know how to create a DataSet?

    Firstly, it makes a (slight) difference what RDBMS you're using but, for the
    sake of argument, let's say you're using SQL Server...

    You'll need to reference the System.Data namespace, and use an appropriate
    connection string, something like this:

    Data Source=myServerAddress;Initial Catalog=myDataBase;User
    Id=myUsername;Password=myPassword;

    For more specific examples, see here:
    http://www.connectionstrings.com/?carrier=sqlserver2005

    string strConnectionString = "<...connection string - see above...>";

    using (SqlConnection objSqlConnection = new
    SqlConnection(strConnectionString))
    {
    objSqlConnection.Open();
    using (SqlCommand objSqlCommand = new SqlCommand(pstrSQL,
    objSqlConnection))
    {
    using (SqlDataAdapter objDA = new SqlDataAdapter(objSqlCommand))
    {
    using (DataSet objDataSet = new DataSet())
    {
    objDA.Fill(objDataSet);
    objSqlConnection.Close();
    return (objDataSet);
    }
    }
    }
    }


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 6, 2007
    #4
    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. =?Utf-8?B?Um9ieSBFaXNlbmJyYXVuIE1hcnRpbnM=?=

    Binding controls with datasourse

    =?Utf-8?B?Um9ieSBFaXNlbmJyYXVuIE1hcnRpbnM=?=, Dec 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    442
    S. Justin Gengo
    Dec 12, 2005
  2. =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=

    datasourse 2.0 question

    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, May 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    370
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
    May 10, 2006
  3. ohood

    datasourse

    ohood, Apr 3, 2007, in forum: Java
    Replies:
    1
    Views:
    497
    Oliver Wong
    Apr 3, 2007
  4. Greg Smith
    Replies:
    1
    Views:
    441
    Mark Rae
    May 31, 2007
  5. gridview without using any datasourse control

    , Jan 17, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    118
Loading...

Share This Page