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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:43:29+00:00 2026-05-20T07:43:29+00:00

I am changing a console app login over to a web based application and

  • 0

I am changing a console app login over to a web based application and recieve the following error about an Unhandled exception.

In the console app I have the following line of code which resides in the StoredProcDemo class:

 StoredProcDemo spd = new StoredProcDemo();

In the Web Application I have:

Login spd = new Login(); 

I am not sure what to change it over to. Could someone shed some insight thanks and maybe why? Thanks so much.

Here is the full code if needed.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlTypes;

namespace GUI_Login
{
    public partial class Login : System.Web.UI.Page
    {
            SqlConnection conn = null;
            SqlParameter parmReturnValue;

            Login spd = new Login();

        protected void Page_Load(object sender, EventArgs e)
        {   
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            RunStoredProcParams();
        }

        public void RunStoredProcParams()
        {
            //run simple stored procure
            spd.RunStoredProcParams();

            int Result;
            Result = -1;

            conn = conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=c:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\UserDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True; Integrated Security=SSPI");
            conn.Open();

            try
            {
                //create and open a connection object
                conn = conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=c:\\Program Files\\Microsoft SQL Server\\MSSQL10.SQLEXPRESS\\MSSQL\\DATA\\UserDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True; Integrated Security=SSPI");
                conn.Open();

                //Create the command object indentifying the stored procedure
                SqlCommand cmd = new SqlCommand("PassParamUserID", conn);

                //set the command object so it knows to execute a stored procedure
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@FirstName", txtUserName.Text));
                parmReturnValue = cmd.Parameters.AddWithValue("@UserId", SqlDbType.Int);
                parmReturnValue.Direction = ParameterDirection.ReturnValue;

                cmd.ExecuteNonQuery();
                Result = Convert.ToInt32(cmd.Parameters["@UserId"].Value);
                conn.Close();

                // lblResult.Text = Result;
                if (Result > 0)
                {
                    lblResult.Text = ("User does exist in database");
                }
                else if (Result < 0)
                {
                    lblResult.Text = ("Denied, try another user name");
                }
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

        }
  • 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-20T07:43:29+00:00Added an answer on May 20, 2026 at 7:43 am

    Even ignoring RunStoredProcParams you’ll get a stack overflow as soon as you try to create a new instance:

    public partial class Login : System.Web.UI.Page
    {
        // Removed extraneous stuff...
        Login spd = new Login();
    }
    

    Why do you want every instance of Login to have a reference to another instance of Login, which it creates immediately?

    Basically the constructor is going to be called recursively until it goes bang.

    What are you trying to do here, and why? In the console app you may well be creating an instance of StoredProcDemo, but I’m sure it wouldn’t be within StoredProcDemo itself (as an instance variable initializer). Perhaps it’s in Program or something similar? That would make more sense.

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

Sidebar

Related Questions

I have a console application written in c++. It simply reads an integer from
So i have this code in a .NET 2.0 console app: [DllImport(kernel32.dll)] private static
I have seen posts on changing console true type font and console colors (rgb)
I have a console app, and a class library. I'm making changes to the
I'm using (and changing) an Excel-File from C#, like: Excel.Application app = new Excel.Application();
Im trying to install a simple Zend Framework based web application on a Linux
I have a simple self hosted WCF Console windows app, and I can connect
When changing the project from console to windows app, I still am not able
changing a static resource during runtine is something that sounds not possible. I have
When changing the selected item in a ListBox, I'm getting a weird error where

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.