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

  • Home
  • SEARCH
  • 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 8345149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:35:33+00:00 2026-06-09T06:35:33+00:00

I have a query that will return a value in this case and inventory

  • 0

I have a query that will return a value in this case and inventory category. If the user enters a certain box number then the form should disable if it is anything else the form will enable. The problem is I use the ExecuteScalar and need to compare that value to a string “AP”. I am pretty new to C# and cannot figure out how to do this. Here is my code so far:

private void hide_apple_controls()
{
        SqlCommand cmd = new SqlCommand();
        Object invCat;
        cmd.CommandText = "SELECT itm.inv_cat FROM " +
                          "t_item_master itm " +
                          "LEFT OUTER JOIN  t_box box (NOLOCK) ON box.product_code LIKE itm.item_number " +
                          "where box.box_id = @box_id ";

        cmd.Parameters.Add("@box_id", SqlDbType.VarChar).Value = boxBox.Text;

        cmd.CommandType = CommandType.Text;
        cmd.Connection = this.sqlConnection1;
        this.sqlConnection1.Open();
        SqlDataAdapter adpt = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        adpt.Fill(ds);
        invCat = cmd.ExecuteScalar();          
        this.sqlConnection1.Close();

        string ap = "AP";

        if (invCat == ap ) 
        {
            disable_qc_form();
        }

        enable_qc_form();
}
  • 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-09T06:35:34+00:00Added an answer on June 9, 2026 at 6:35 am

    in the if condition, you need the else clause.

    if (invCat == ap ) 
       disable_qc_form();
    else
       enable_qc_form();
    

    Without the else , your last line will execute no matter what.
    With the else it will execute only if the invCat == ap doesn’t evaluate to true.

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

Sidebar

Related Questions

I have a query that will be put into a procedure, and it will
I have a page a query that will set a table to 0 or
I have a problem with an sql query that will not work if I
I want to add an extra field to my query that will have the
I have a simple query: $query = new WP_Query('showposts=5'); that will obviously display 5
I have a PHP code, that will run a Select query to check if
I have have this query that i want to execute. SELECT warehouse.expiry_date, pharmacy.expiry_date, drugs.active_substance,
I have a method that will return a list of suggested orders. If the
I have a function that will perform a SELECT query from some db and
I am using in C# MYsql .I have query that works if I run

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.