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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:06:02+00:00 2026-05-23T10:06:02+00:00

I am working on an web application, which is a B2B portal App. I

  • 0

I am working on an web application, which is a B2B portal App. I am following 2 tier architecture for my app.
Below is a piece of code that registers a company to my website

/// <summary>
        /// Register Company with the business bazaar
        /// </summary>
        /// <param name="registration"></param>
        /// <returns></returns>
        public static bool RegisterCompany(Registration registration)
        {
            bool result;
            using (var helper = new DbHelper())
            {
                _commandText = "sp_RegisterCompany";
                var success = new SqlParameter("@Success", SqlDbType.Bit, 1, ParameterDirection.Output, true, 0, 0,
                                               "Result", DataRowVersion.Default, 0);
                var parameters = new[]
                                     {
                                         new SqlParameter("@Name",registration.RegisteredUser.Name),
                                        new SqlParameter("@Designation",registration.Designation ),
                                        new SqlParameter("@Email",registration.RegisteredUser.Email ),
                                        new SqlParameter("@AltEmail",registration.RegisteredUser.AlternateEmail ),
                                        new SqlParameter("@City",registration.City ),
                                        new SqlParameter("@State",registration.State ),
                                        new SqlParameter("@Country",registration.Country ), 
                                        new SqlParameter("@Telephone",registration.Telephone ),
                                        new SqlParameter("@Mobile",registration.Mobile ),
                                        new SqlParameter("@CompanyName",registration.CompanyName ),
                                        new SqlParameter("@Website",registration.Website ),
                                        new SqlParameter("@LoginId",registration.RegisteredUser.UserName ),
                                        new SqlParameter("@Password",registration.RegisteredUser.Password ),
                                        success,
                                     };
                helper.ExecuteScalar(_commandText, CommandType.StoredProcedure, parameters);
                result = (bool) success.Value;
            }
            return result;

        }

What I want to say is that i am using Static methods for all my datalayer methods. As I have gone through various articles on the web stating that Static methods has more advantages over Non-Static methods. So I have designed my code that way. But few days ago I came across ab article that says static methods are useful when you design some utilities for your class other wise use Non-Static, as same static objects are avalaible to other users. So I just want to make clear which approach to follow, static or non static.

I am using class in this format:

public sealed class MyClass
{
    private MyClass(){}
    public static DataTable GetUserInfoByUserId(int userId)
    {
       // My datalayer code goes here
    }
}

SO i am cofused if making the above method static , would’nt make the data of user 1 available to user 2 accessing the application simultaneously. Basically , I want to know the flaws of this design.

UPDATED
Below is my class, showing my approach

#region

using System.Data;
using System.Data.SqlClient;
using System;

#endregion

namespace InnovativeTechnosoft.BusinessBazaar.Core
{
    public sealed class UserData
    {
        private static string _commandText = string.Empty;


        /// <summary>
        /// Takes username and password as input and sets 
        /// the current user in sessionif the user authenticate
        /// successfully
        /// </summary>
        /// <param name="userName">username as string</param>
        /// <param name="password">password as string</param>
        /// <returns>datatable</returns>
        public static DataTable IsAuthenticated(string userName, string password)
        {
            DataTable dtResult;
            using (var helper = new DbHelper())
            {
                _commandText = "sp_AuthenticateUsers";
                var parameters = new[]
                                     {
                                         new SqlParameter("@username", userName),
                                         new SqlParameter("@password", password),
                                     };
                dtResult = helper.ExecuteSelect(_commandText, CommandType.StoredProcedure, parameters);
            }

            return dtResult;
        }

        /// <summary>
        /// Checks for username if it exists or not
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static bool IsExistingUser(string userName)
        {
            bool result;
            using (var helper = new DbHelper())
            {
                _commandText = "sp_IsExistingUserName";
                var success = new SqlParameter("@Success", SqlDbType.Bit, 1, ParameterDirection.Output, true, 0, 0,
                                              "Result", DataRowVersion.Default, 0);
                var parameters = new[]
                                     {
                                         new SqlParameter("@userName", userName),
                                         success,
                                     };
                helper.ExecuteScalar(_commandText, CommandType.StoredProcedure, parameters);
                result = (bool)success.Value;
            }

            return result;
        }

        /// <summary>
        /// Register Company with the business bazaar
        /// </summary>
        /// <param name="registration"></param>
        /// <returns></returns>
        public static bool RegisterCompany(Registration registration)
        {
            bool result;
            using (var helper = new DbHelper())
            {
                _commandText = "sp_RegisterCompany";
                var success = new SqlParameter("@Success", SqlDbType.Bit, 1, ParameterDirection.Output, true, 0, 0,
                                               "Result", DataRowVersion.Default, 0);
                var parameters = new[]
                                     {
                                         new SqlParameter("@Name",registration.RegisteredUser.Name),
                                        new SqlParameter("@Designation",registration.Designation ),
                                        new SqlParameter("@Email",registration.RegisteredUser.Email ),
                                        new SqlParameter("@AltEmail",registration.RegisteredUser.AlternateEmail ),
                                        new SqlParameter("@City",registration.City ),
                                        new SqlParameter("@State",registration.State ),
                                        new SqlParameter("@Country",registration.Country ), 
                                        new SqlParameter("@Telephone",registration.Telephone ),
                                        new SqlParameter("@Mobile",registration.Mobile ),
                                        new SqlParameter("@CompanyName",registration.CompanyName ),
                                        new SqlParameter("@Website",registration.Website ),
                                        new SqlParameter("@LoginId",registration.RegisteredUser.UserName ),
                                        new SqlParameter("@Password",registration.RegisteredUser.Password ),
                                        success,
                                     };
                helper.ExecuteScalar(_commandText, CommandType.StoredProcedure, parameters);
                result = (bool) success.Value;
            }
            return result;

        }

        /// <summary>
        /// Recovers Password 
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool RecoverPassword(string email, out string password)
        {
            bool result;
            password = string.Empty;
            using (var helper = new DbHelper())
            {
                _commandText = "sp_RecoverPassword";
                var success = new SqlParameter("@Success", SqlDbType.Bit, 1, ParameterDirection.Output, true, 0, 0,
                                               "Result", DataRowVersion.Default, 0);
                var pwd = new SqlParameter("@Password", SqlDbType.NVarChar, 50, ParameterDirection.Output, true, 0, 0, "Password", DataRowVersion.Default, string.Empty);
                var parameters = new[]
                                     {
                                        new SqlParameter("@Email",email ),
                                        success,
                                     };
                helper.ExecuteScalar(_commandText, CommandType.StoredProcedure, parameters);
                result = (bool)success.Value;
                password = Convert.ToString(pwd.Value);
            }
            return result;
        }
        /// <summary>
        /// Update  Password 
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool UpdatePassword(int userId,string password)
        {
            bool result;
            using (var helper = new DbHelper())
            {
                _commandText = "sp_UpdatePassword";
                var success = new SqlParameter("@Success", SqlDbType.Bit, 1, ParameterDirection.Output, true, 0, 0,
                                               "Result", DataRowVersion.Default, 0);
                var parameters = new[]
                                     {
                                         new SqlParameter ("@UserId",userId),
                                        new SqlParameter("@Password",password ),
                                        success,
                                     };
                helper.ExecuteScalar(_commandText, CommandType.StoredProcedure, parameters);
                result = (bool)success.Value;
            }
            return result;
        }

    }
}

It would be a great help.

Regards
Amit Ranjan

  • 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-23T10:06:02+00:00Added an answer on May 23, 2026 at 10:06 am

    You can uses static functions, but you should avoid static variables or members at all. In short, don’t “save” any information in static context. These are available in application scope and that may be the same for different requests from different users.

    Running data access operations in static functions should be no problem.

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

Sidebar

Related Questions

i am working in asp.net mvc 3 web application which uses razor code. and
I am working on a web-application in which dynamically-created images are used to display
I'm working on a web based application which uses a JSON over HTTP based
I'm working profesionally on a php web application which contains contacts, among other data.
Well, simple question. I'm working with VS2008 on an ASP.NET web application which has
I am working on a web application in Java which gets data from servlets
I am working on a web application (using Grails) which will generate a gift
I am working on a ASP.Net web forms application which I inherited from a
I am currently working on a web application. I was just wondering which has
I am working on a .NET 3.5 project which consists of a web application

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.