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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:37:10+00:00 2026-06-13T18:37:10+00:00

How do i return a Userid in web method and use that returned result

  • 0

How do i return a Userid in web method and use that returned result in website ASP.NET,make it session variable in order to use it on different webpages in ASP.NET?

[WebMethod]
public bool UserLogin(string EmailAdd, string Password)
{

        SqlConnection myConnection = new SqlConnection(@"user id=BankUser;password=Computer1;server=(local)\sql2008;database=BillionBank;");
        myConnection.Open();
        SqlCommand myCommand = new SqlCommand("SELECT * FROM [BillionBank].[dbo].[tblCustomerProfile] WHERE EmailAdd='" + EmailAdd + "' AND Password ='" + Password + "'", myConnection);
        SqlDataReader myreader;
        myreader = myCommand.ExecuteReader();
        if (myreader.Read())
        {
            return true;
        }
        else
            return false;
    }

this is my code i want to return a Userid as a result and use it in website as a session variables,when am calling the web method in my website

  • 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-13T18:37:12+00:00Added an answer on June 13, 2026 at 6:37 pm
      public string GetUserID(string EmailAdd, string Password)
        {
            SqlConnection myConnection = new SqlConnection(@"user id=BankUser;password=Computer1;server=(local)\sql2008;database=BillionBank;");
            myConnection.Open();
            SqlCommand myCommand = new SqlCommand("SELECT * FROM [BillionBank].[dbo].[tblCustomerProfile] WHERE EmailAdd='" + EmailAdd + "' AND Password ='" + Password + "'", myConnection);
            SqlDataReader myreader;
            string result = "";
    
            myreader = myCommand.ExecuteReader();
            if (myreader.Read())
            {
                result = Convert.ToString(myreader["UserID"]);
            }
    
            return result;
    
        }
    
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Session["UserID"] = GetUserID(YOUR_EMAILID, YOUR_PASSWORD);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following model method inside my asp.net MVc web application:- public IQueryable<User>
Dear all how could im set response status in Asp.net Web service method ?
I use asp.net and web forms. In my project I have asmx web service
What return type should one return from a method that is getting rows from
I am creating a Web Service using ASP.NET C#. I am sending various data
I'm converting from the WCF Web API to the new ASP.NET MVC 4 Web
My web method returns object 'User' that has a lot of properties: Id, Nick,
I am developing an ASP.Net MVC 3 Web application with Entity Framework 4. When
This is web single sign on code that runs on a .net 3.5 winform.
why select 'aaa' =0 return 1 (TRUE) if i have a table like userid

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.