|
-
Sep 22nd, 2012, 02:45 PM
#1
Thread Starter
Member
Count number of records...
I am at a loss here... (Visual Studio 2012 VB, MSSQL 2008)
Is there a way to count the number of records in a sqldatasource without displaying a grid on my page?
Code:
<asp:SqlDataSource ID="sqlMessages" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnectionString %>" SelectCommand="SELECT * FROM [Messages] WHERE ([SentTo] = @SentTo) ORDER BY [MessageDate] DESC">
<SelectParameters>
<asp:SessionParameter Name="SentTo" SessionField="MemberID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
How can I get the number of records that are returned? another question I have a field "MessageStatus" how can I get the number or records that are listed as "new" as well... Here is what I would like to display...
lblMessages.text = "Total Message: " WHAT DO I PUT HERE "Total New Messages: " WHAT DO I PUT HERE????
Last edited by acrow; Sep 22nd, 2012 at 02:49 PM.
-
Sep 22nd, 2012, 10:10 PM
#2
Re: Count number of records...
Why don't u use MSSQL with a good ol stored procedure?You have it installed anyway.It may be done i sqldatasource but i would urge you not to use this control.Also don't use "*" for selecting data, use the columns names.
The "as new" question, is blurry.What do you define as new?If you define a column named as messagestatus in sql then you can "select blah, form tableblah WHERE [SentTo] = @SentTo and messagestatus=1 order by etc etc.
Assuming that when messagestatus gets the number 1 then it's a new message,or unread message or something.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|