I have this SqlSataSource (aspx 2.0):
<asp:SqlDataSource ID="ArtiestenSource" Runat="server"
SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album) AS
albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
dbo.muziek GROUP BY artiest"
ConnectionString="Server=DESERVER;User
ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
ProviderName="System.Data.SqlClient">
</asp:SqlDataSource
Maybe someone knows how to retrieve the number of rows of this datasource?
(ArtiestenSource.RecordCount doesn't work. )
Also: I would display this number of rows like this:
<% response.write(ArtiestenSource.RecordCount) %
But I don't doubt there is a typical dot net 2.0 way of displaying this
result. (So, something else then <% response.write() %>.
If I am right about that, does someone know what right way is?
Thanks!
DaanYou should be able to extract the DataSet and pull the number out (would
give you code, but I do not have the 2.0 machine up and running). As far as
how to embed the number in a page, you have two choices.
1. Add a label and set the Text property
2. Use data binding <%# =variableName %> - just set the variableName in the
back and make sure it is accessible. You will have to run Page.DataBind() to
ensure it is bound, however.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
************************************************
Think Outside the Box!
************************************************
"Daan" <daan@.nergens.com> wrote in message
news:cdql5b$uat$1@.news.cistron.nl...
> Hi!
> I have this SqlSataSource (aspx 2.0):
> <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album) AS
> albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> dbo.muziek GROUP BY artiest"
> ConnectionString="Server=DESERVER;User
> ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
> ProviderName="System.Data.SqlClient">
> </asp:SqlDataSource>
> Maybe someone knows how to retrieve the number of rows of this datasource?
> (ArtiestenSource.RecordCount doesn't work. )
> Also: I would display this number of rows like this:
> <% response.write(ArtiestenSource.RecordCount) %>
> But I don't doubt there is a typical dot net 2.0 way of displaying this
> result. (So, something else then <% response.write() %>.
> If I am right about that, does someone know what right way is?
> Thanks!
> Daan
Hi!
Does anyone know how to extract the DataSet from a SqlDataSource?
(I have really been searching and trying, but I can't figger it out -> a
real newbie?)
Thanks!
Daan
"Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld@.comcast.netNoSpamM>
schreef in bericht news:%231cgHrLcEHA.1656@.TK2MSFTNGP09.phx.gbl...
> You should be able to extract the DataSet and pull the number out (would
> give you code, but I do not have the 2.0 machine up and running). As far
as
> how to embed the number in a page, you have two choices.
> 1. Add a label and set the Text property
> 2. Use data binding <%# =variableName %> - just set the variableName in
the
> back and make sure it is accessible. You will have to run Page.DataBind()
to
> ensure it is bound, however.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ************************************************
> Think Outside the Box!
> ************************************************
> "Daan" <daan@.nergens.com> wrote in message
> news:cdql5b$uat$1@.news.cistron.nl...
> > Hi!
> > I have this SqlSataSource (aspx 2.0):
> > <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> > SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album)
AS
> > albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> > CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> > dbo.muziek GROUP BY artiest"
> > ConnectionString="Server=DESERVER;User
> > ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
> > ProviderName="System.Data.SqlClient">
> > </asp:SqlDataSource>
> > Maybe someone knows how to retrieve the number of rows of this
datasource?
> > (ArtiestenSource.RecordCount doesn't work. )
> > Also: I would display this number of rows like this:
> > <% response.write(ArtiestenSource.RecordCount) %>
> > But I don't doubt there is a typical dot net 2.0 way of displaying this
> > result. (So, something else then <% response.write() %>.
> > If I am right about that, does someone know what right way is?
> > Thanks!
> > Daan
Daan:
Here is another way to get the record count: The SqlDataSource has an event
called "Selected." It passes in a SqlDataSourceStatusEventArgs, which has a
property called "AffectedRows." I just tried hooking this event after calling
a simple select to the Products table of Northwinds and got the rowcount.
Chuck
"Daan" wrote:
> Hi!
> Does anyone know how to extract the DataSet from a SqlDataSource?
> (I have really been searching and trying, but I can't figger it out -> a
> real newbie?)
> Thanks!
> Daan
>
>
> "Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld@.comcast.netNoSpamM>
> schreef in bericht news:%231cgHrLcEHA.1656@.TK2MSFTNGP09.phx.gbl...
> > You should be able to extract the DataSet and pull the number out (would
> > give you code, but I do not have the 2.0 machine up and running). As far
> as
> > how to embed the number in a page, you have two choices.
> > 1. Add a label and set the Text property
> > 2. Use data binding <%# =variableName %> - just set the variableName in
> the
> > back and make sure it is accessible. You will have to run Page.DataBind()
> to
> > ensure it is bound, however.
> > --
> > Gregory A. Beamer
> > MVP; MCP: +I, SE, SD, DBA
> > ************************************************
> > Think Outside the Box!
> > ************************************************
> > "Daan" <daan@.nergens.com> wrote in message
> > news:cdql5b$uat$1@.news.cistron.nl...
> > > Hi!
> > > > I have this SqlSataSource (aspx 2.0):
> > > > <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> > > SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album)
> AS
> > > albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> > > CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> > > dbo.muziek GROUP BY artiest"
> > > ConnectionString="Server=DESERVER;User
> > > ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
> > > ProviderName="System.Data.SqlClient">
> > > </asp:SqlDataSource>
> > > > Maybe someone knows how to retrieve the number of rows of this
> datasource?
> > > (ArtiestenSource.RecordCount doesn't work. )
> > > > Also: I would display this number of rows like this:
> > > <% response.write(ArtiestenSource.RecordCount) %>
> > > > But I don't doubt there is a typical dot net 2.0 way of displaying this
> > > result. (So, something else then <% response.write() %>.
> > > If I am right about that, does someone know what right way is?
> > > > Thanks!
> > > > Daan
> > >
0 comments:
Post a Comment