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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:50:24+00:00 2026-05-11T11:50:24+00:00

I am working on my project and having strange result with asp.net C# and

  • 0

I am working on my project and having strange result with asp.net C# and stored procedure that returns scalar variable. In short, I am trying to return user name, however I get only the first letter from the name, which is strange.

I went trough the code couple dozen of times; however i still cannot find the error. I would really appreciate if somebody can find the mystake

Here is my stored procedure:

set ANSI_NULLS ON GO set QUOTED_IDENTIFIER ON go  ALTER PROCEDURE [one_two].[team5GetLostPassword] (     @user_password varchar(50),     @email varchar(50),     @user_name varchar(50) out,     @user_exist int out ) AS BEGIN     declare @user_fname varchar(50);     declare @user_lname varchar(50);     declare @user_id int;      set @user_exist = 0;     SET NOCOUNT ON;      IF EXISTS(select user_email from team5_user_detail where user_email LIKE @email)     begin         set @user_id = (select userid from team5_user_detail where user_email Like @email);         update team5_user Set user_password = @user_password where userid = @user_id;         set @user_name = (select user_lname from team5_user_detail where userid = @user_id);         set @user_exist = 1;     end END 

and my C# code

protected bool IsValidUser() {     myConn = new SqlConnection(myConStr);     myCommand = new System.Data.SqlClient.SqlCommand('team5GetLostPassword', myConn);     myCommand.CommandType = CommandType.StoredProcedure;     myCommand.Parameters.AddWithValue('@user_password', userPasswordEncrypted);     myCommand.Parameters.AddWithValue('@email', userEmailString);      myCommand.Parameters.AddWithValue('@user_name', '').Direction = ParameterDirection.Output;     myCommand.Parameters.AddWithValue('@user_exist', 0).Direction = ParameterDirection.Output;      try     {         myConn.Open();         myCommand.ExecuteScalar();         userExist = myCommand.Parameters['@user_exist'].Value.ToString();         userName = myCommand.Parameters['@user_name'].Value.ToString();     }     catch (Exception exep)     {     }     finally     {         myConn.Close();     }      if (userExist.Contains('1'))         return true;     else         return false; } 
  • 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. 2026-05-11T11:50:24+00:00Added an answer on May 11, 2026 at 11:50 am

    You need to set the Size property of the SqlParameter to the length of data you want returned.

    I don’t think you want to use ExecuteScalar() in this case. ExecuteScalar() is used when you want to return the first column of the first row in the result set. Since you are trying get values from output parameters, you want to use ExecuteNonQuery().

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

Sidebar

Related Questions

I am having a strange problem. I am working on a .net windows project
I am working on a asp.net project having a three-layered implementation. DataAccess Layer is
I am currently working on a ASP.NET MVC 4 Web Application project that must
I'm having an excessively strange issue. I'm working on a project and it's being
I am currently working on a project that is looking at having a database
I'm working on a project involving the .NET ReportViewer, and I'm having issues connecting
I am having trouble trying to put in data for this project I'm working
I'm working on a SaaS project that will have each customer having an instance
I am having tons of fun working on a big project that was, for
I am working on an intranet project that is having the majority of its

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.