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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:05:54+00:00 2026-06-06T04:05:54+00:00

When a user logs in with his UserName , I send the UserName to

  • 0

When a user logs in with his UserName, I send the UserName to the next page as below code in Page_Load

 lblCmpUserName.Text = Server.UrlDecode(Request.QueryString["Parameter"].ToString());

and then I want to store the “Company details” with the UserName in a SQL Server 2008 table.

I got the error

Must declare the scalar variable “@lblCmpUserName”

Code:

    protected void BtnCmpApproval_Click(object sender, EventArgs e)
    {
       SqlConnection SqlCon = new SqlConnection(GetConnectionString());
       string query = "INSERT INTO Company_Info2 VALUES (@lblCmpUserName, @txtCmpName,  @txtRegCountry, @txtCmpRegNo, @txtCmpEstdate,@AFU1, @txtCmpAddress, @ddlAddrIn)";
       try
       {
          SqlCon.Open();

          SqlCommand cmd = new SqlCommand(query, SqlCon);
          cmd.CommandType = CommandType.Text;
          cmd.Parameters.AddWithValue("@UserName", lblCmpUserName.Text);
          cmd.Parameters.AddWithValue("@Cmp_Name", txtCmpName.Text);
          cmd.Parameters.AddWithValue("@Commercial_RegNo", txtRegCountry.Text);
          cmd.Parameters.AddWithValue("@Comm_Country", txtCmpRegNo.Text);
          cmd.Parameters.AddWithValue("@Cmp_EstablishDate", txtCmpEstdate.Text);
          cmd.Parameters.AddWithValue("@Cmp_DocPath", AFU1.FileName);
          cmd.Parameters.AddWithValue("@txtCmpAddress", txtCmpAddress.Text);
          cmd.Parameters.AddWithValue("@ddlAddrIn", ddlAddrIn.SelectedItem.Text);

          cmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
         throw new Exception(ex.Message);
      }
      finally
      { 
         SqlCon.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-06-06T04:05:56+00:00Added an answer on June 6, 2026 at 4:05 am

    I got the solution, I made a mistake in my INSERT query.

    It should be like this.

    string query="INSERT INTO Company_Info2 VALUES     (@UserName,@Cmp_Name,@Comm_Country,
        @Commercial_RegNo,@Cmp_DocPath,  
        @Cmp_EstablishDate,@Cmp_Address,@IsAddress)";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a php/javascript chat. When the user logs in, his/her username is inserted
I have a login page which the user logs in with a username and
When a user logs in to a Windows Active Directory environment, his/her password is
When a user logs in based on default Forms Authentication method, the server creates
I want to send an SMS as a User logs in to the sql
Any user who logs in needs to provide username, password and domain. For that
A user logs in to his control panel and sees his incoming messages. Near
I have a facebook app and a user logs in and uses it. Simple.
I have a pop-up window a user logs into, once they are logged in
I have a website and when the user logs in they can click on

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.