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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:20:39+00:00 2026-06-18T00:20:39+00:00

ok so i have a text box and a button where i will enter

  • 0

ok so i have a text box and a button where i will enter a number and press the button. I then want a message box to display if the value has been found or not.

I put all my functions in a model class then call them for the GUI part.
heres what i tried so the sql function (ticket is the name of the table and ID is the value im trying to find):

  public void rebateslip(int ticketID)
    {
        SqlCommand myCommand  = new SqlCommand("SELECT ID FROM ticket WHERE ID = @ticketID", con);
        SqlDataAdapter sqlDa = new SqlDataAdapter(myCommand);

        myCommand.Parameters.AddWithValue("@ID", ticketID);


    }

and than for the button event handler i have this:

 private void buttonPrintRebateSlip_Click(object sender, EventArgs e)
    {

            if (textBoxRebateSlip = model.rebateslip(ticketID)
            {
                MessageBox.Show("Found ticket");
            }
            else
            {
                MessageBox.Show("Ticket not in database");
            }

    }

but it says ticketID does not exist

  • 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-18T00:20:40+00:00Added an answer on June 18, 2026 at 12:20 am

    you should change your model.rebateslip method so that it return a bool, and execute your command, then it should look more or less like this: (don’t have the SqlCommand methods in mind, nor the reader’s ones, but according to my memory it looks like this)

    public bool rebateslip(int ticketID)
    {
        SqlCommand myCommand  = new SqlCommand("SELECT ID FROM ticket WHERE ID = @ticketID", con);
        SqlDataAdapter sqlDa = new SqlDataAdapter(myCommand);
    
        myCommand.Parameters.AddWithValue("@ticketID", ticketID);
        var reader = myCommand.Execute();
        return reader.HasRows;    
    }
    

    then you should do something like @Ezekiel said in his answer:

    int id;
    if (!int.TryParse(textBoxRebateSlip.Text, out id)) return;
    
    if (model.rebateslip(id))
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If i have to enter any value in that text box and press tab
I have a text box and a button, if I enter some text in
I will have a text box where user can enter 0-9999 . If the
I have a text box when we enter the value in to text box
I have a UI with a search text box and a button that that
I have event Button that creates text box in run time. Private Sub Button1_Click(ByVal
I have a button next to a text box and when I click the
I have 2 textBox and 1 button! I want to insert text to one
I have a text box in my page which the user will type something
I have a textbox and button in an aspx page. I enter some text

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.