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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:50:45+00:00 2026-05-31T14:50:45+00:00

Hi guys have an issue with the timer basically i have the seconds variable

  • 0

Hi guys have an issue with the timer basically i have the seconds variable set to 60 and when its counted down to 0 i want my SQL command to run to change the database and then for it to produce a messagebox saying ”card confiscated” or something then once they click ok the application to stop

private void timer1_Tick(object sender, EventArgs e)
{
    if (seconds < 1)
    {
        MessageBox.Show("Option timer Expired Card Confiscated please contact your local branch");
        timer1.Enabled = false;
        sqlCommandTimer.Parameters["@cardNum"].Value = Class1.cardNumber;
        sqlCommandTimer.Parameters["@confiscated"].Value = true;
        try
        {
            sqlCommandTimer.Connection.Open();
            sqlCommandTimer.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            Application.Exit();
            sqlCommandTimer.Connection.Close();     
        }

    }
    else
    {
        seconds--;
        listBox2.Items.Add(seconds);
    }

this is my SQL command

UPDATE       dbo.ATMCards
SET                confiscated = @confiscated
WHERE        (cardNumber = @cardNum)

any help on what im missing would be greatly appreciated 🙂 thanks

edit: oh crap sorry forgot to add my problem it goes to 0 then basically continually spams the message

  • 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-31T14:50:47+00:00Added an answer on May 31, 2026 at 2:50 pm

    MessageBox.Show stops the rest of your code being executed until the user clicks OK/Cancel/whatever, but the timer will keep on ticking and, since you are checking seconds < 1 rather than == 0, producing more messageboxes, and eventual SQL calls.

    Rather than

    1. Show messagebox
    2. Stop timer
    3. Run SQL

    I would suggest you

    1. Stop timer
    2. Run SQL
    3. Show messagebox

    Stopping the timer first ensures that the seconds < 1 branch should only ever happen once (although I’d still check == 0 instead, and possibly change your else to else if (seconds > 0); running the SQL second ensures that, by the time the message is shown, the user’s card has indeed been confiscated.

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

Sidebar

Related Questions

Hey guys I have a little issue here. I have a panel where I
When reading about SQL Injection and XSS i was wondering if you guys have
Hi guys I have a google apps account set up and even set up
Hey guys I'm running into a weird issue.. Basically, a user logs into a
Hi guys i have an issue currently when using a Socket to send data.
I want to build a simple time ticker. Basically I will have a global
do you guys have any idea how to edit the the labels in the
Thus far you guys have been wildly helpful with me getting this little ditty
Python list comprehensions are nice, but near impossible to debug. You guys have any
guys i have arrays in which i have to match this kind of 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.