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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:01:33+00:00 2026-05-23T05:01:33+00:00

I am learning C# and am using Visual Studio 2010 to build a payroll

  • 0

I am learning C# and am using Visual Studio 2010 to build a payroll program. I get an error “Cannot implicitly convert type ‘int’ to ‘short'”.

My code is :

private void btn_add_Click(object sender, EventArgs e)
        {
            try
            {
                // Get service instance
                var employerPeriodService = Program.Kernel.Get<IEmployerPeriodService>();

                // Get new code
                var newCode = employerPeriodService.GenerateSAPCode();

                // Create object
                var employerPeriodAdd =
                    new EmployerPeriod
                    {
                        Code = newCode,
                        Name = newCode,
                        U_Tax_year = int.Parse(cb_tax_year.Text),
                        //U_Day_hrs = cb_number_hours.Text,
                        //U_Week_days = cb_number_days_week.Text,
                        //U_Week_hrs = txt_number_hours_week.Text,
                        //U_Month_days = cb_number_days_month.Text,
                        //U_Month_hrs = txt_number_hours_month.Text,
                        //U_Fortnight_days = cb_number_days_fortnight.Text,
                        //U_Fortnight_hrs = txt_number_hours_fortnight.Text,
                        //U_Weeks_in_month = cb_avg_weeks_month.Text,
                        //U_No_of_Fortnights = cb_avg_fortnights_month.Text,
                        U_Starting_period = Convert.ToDateTime(dateTimePicker1.Text),
                        U_Ending_period = Convert.ToDateTime(dateTimePicker2.Text)

                        //U_Comments = txt_comments.Text
                    };

                // Save record
                employerPeriodService.AddEmployerPeriod(employerPeriodAdd);

                MessageBox.Show("Employer Payroll Period Added Successfully. Intake Ref: " + newCode.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (RulesException ex)
            {
                MessageBox.Show(ex.GetErrorMessages(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

In Microsoft SQL Server where my database is, U_Tax_year is defined as smallint. What do I need to do to solve this error. Do I convert what I get from the combo box ‘cb_tax_year.Text’ to int and how do I achieve this.

Any help appreciated.

  • 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-23T05:01:34+00:00Added an answer on May 23, 2026 at 5:01 am

    I suspect it’s as simple as changing this:

    U_Tax_year = int.Parse(cb_tax_year.Text),
    

    to this:

    U_Tax_year = short.Parse(cb_tax_year.Text),
    

    Basically you should check the type of the U_Tax_year property and make sure you parse the text appropriately so that the result of the RHS of the = sign is assignment-compatible with the property type.

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

Sidebar

Related Questions

I'm using Visual Studio 2010 Beta 2 to get a head start on learning
I'm using the Beta 2 version of Visual Studio 2010 to get a head
I'm about to upgrade to Visual Studio 2010, and I'm learning that there are
I'm currently using the Visual Studio Installer (Setup Project) in Visual Studio 2010 as
I am using Visual Studio 2008 to build my projects. I often take existing
I'm learning how to work with Oracle and am using C#/Visual Studio. Just as
I'm learning to work with SVN using Visual Studio.NET. Everything works fine and all
After learning about how to print out debug messages using Visual Studio's Tracepoint feature,
Now that I've started learning Microsoft's languages and using Visual Studio, any time I
I've recently started learning how to use MFC in Visual Studio. My program uses

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.