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 6131825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:01:33+00:00 2026-05-23T17:01:33+00:00

I used linq to sql many times its work correctly but today something wrong

  • 0

I used linq to sql many times its work correctly but today something wrong

this is code which must select password from users table.
I call this method tell wright… result is not password please see picture.

public void GetPassword(int id) 
    {
        using (HProDataContext db = new HProDataContext())
        {
            _CurrentPassword = (from p in db.users
                                    where p.id == _CurrentID
                                    select p.password).ToString();
        }
    }

this how i use this method

private void btnOK_Click(object sender, RoutedEventArgs e)
    {
        if (listView1.SelectedItems.Count < 1)
        {
            MessageBox.Show("Please Select User");
        }
        else if (listView1.SelectedItems.Count > 1)
        {
            MessageBox.Show("Please Select Only One User");
        }
        else
        {
            _CurrentID = Convert.ToInt32(listView1.SelectedValue);
            GetPassword(_CurrentID);

            if (PasswordBox.Password == _CurrentPassword)
            {
                MessageBox.Show("You r in");
            }
            else
            {
                //MessageBox.Show("Password Is incorrect, please try again");
                MessageBox.Show(_CurrentPassword);
            }

        }

    }

enter image description here

  • 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-05-23T17:01:34+00:00Added an answer on May 23, 2026 at 5:01 pm

    You are missing a SingleOrDefault call or a call to Single, First or FirstOrDefault:

    _CurrentPassword = (from p in db.users
                        where p.id == _CurrentID
                        select p.password).Single().ToString();
    

    Explanation: Your query returns an IEnumerable<string> even if there is only one item returned. You first need to get that item, before you can make a sensible call to ToString(). BTW: I think the call to ToString() is not needed, because p.password already should be a string.

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

Sidebar

Related Questions

I have not hardly touched EF4, but I've used Linq to sql quite a
I have used LINQ to SQL with a update stored procedure to update databases
I used the LINQ to SQL designer in Visual Studio to create an object
Can SQL Server 2000 be used as the database for LINQ to SQL? Does
Let say if I used the Linq to Sql concept to interact with database
This question is similar to this one: LINQ to SQL: GroupBy() and Max() to
i have never used LINQ in any of my projects , i have always
We used the undocumented xp_fileexist stored procedure for years in SQL Server 2000 and
Never used a cache like this before. The problem is that I want to
I used to work in a place where a common practice was to use

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.