Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:25:29+00:00 2026-06-04T01:25:29+00:00

I have the following code: @helper RetrievePhotoWithName(int userid) { var database = Database.Open(SC); var

  • 0

I have the following code:

@helper RetrievePhotoWithName(int userid)
{
    var database = Database.Open("SC");
    var name = database.QuerySingle("select FirstName, LastName, ProfilePicture from UserProfile where UserId = @0", userid);
    var notifications =  database.Query("SELECT COUNT(*) FROM NotificationsTable WHERE UserID = @0 AND MessageWasRead = @1", userid, false);

    var DisplayName = "";
    if(notifications < 1)
    {
        DisplayName = name["FirstName"] + " " + name["LastName"];
    }
    else
    {
        DisplayName = name["FirstName"] + ", you have " + notifications + " new messages.";
    }
    <a href="@Href("~/Home")" title="My Account"><img src="@Href("~/Shared/Assets/Images/" + name["ProfilePicture"] + ".png")" id="MiniProfilePicture" />&nbsp;@DisplayName</a>

    database.Close();
}

which is supposed to count all the rows in my table and either display a “new notifications” message to the user on the web page or just display their name, but it’s not working.

Do not edit this question. The reason I am re-posting this question is because my previous one was changed which resulted in inaccurate responses.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:25:30+00:00Added an answer on June 4, 2026 at 1:25 am

    Since SELECT COUNT(*) is returning a single scalar value, I think you want to use database.QueryValue() instead:

    int notifications =  (int)database.QueryValue("SELECT COUNT(*) FROM NotificationsTable WHERE UserID = @0 AND MessageWasRead = @1", userid, false);
    

    http://msdn.microsoft.com/en-us/library/webmatrix.data.database.queryvalue(v=vs.99).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code class User attr_accessor :name end u = User.new u.name =
I have the following code inside a helper in rails: def custom_options_tag(opts={}) ['am', 'pm'].each
I have a page X.cshtml with the following code: @helper CodeTest{ <h1>Test</h1> } And
I have the following code to generate some spans using cakephp's helper <div id=numberRow>
I have the following code in a Rails 3.2.1 helper that keeps escaping HTML
I have the following code in my application helper. route = ActionController::Routing::Routes.recognize_path(current_uri) controller =
I have the following code require 'test_helper' class ApplicationControllerTest < ActionController::TestCase test should display
Let's say that I have the following code in application_helper.rb : def do_something if
I have following code: <div class='parent'> <div class='left-child'></div> <div class=right-child></div> </div> What I want
I have following code snippet and i am trying to evaluate the time take

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.