1

I am trying to convert text box values in my C# application to Numeric data format saved in an MS Access database. There seems to be a couple of ways to convert text to number. For instance, Convert.ToInt32, Convert.ToInt16, Convert.ToInt64. They all seem to work. I am developing the application on a 64 bit machine running Windows 8.1 and I have no idea which type of conversion I should use. How can the following snippet be updated to adapt it to different versions of Windows?

oleCmd.Parameters.Add("@partyID", OleDbType.Numeric).Value = 
        Convert.ToInt32(comboBoxWorkParty.SelectedValue.ToString());

oleCmd.Parameters.Add("@projectTypeID", OleDbType.Numeric).Value = 
        Convert.ToInt32(comboBoxProjectType.SelectedValue.ToString()); 

1
  • 1
    you will be fine, generally speaking, with Int32. as bsarkar said, the bitness has nothing to do with the OS but rather the type of data itself.... Commented Feb 8, 2015 at 18:02

2 Answers 2

2

Regardless of whether you are using the 64-bit version or the 32-bit version of the Access Database Engine:

  • a Long Integer field in an Access database corresponds to Int32, and
  • an Integer field in an Access database corresponds to Int16.
Sign up to request clarification or add additional context in comments.

2 Comments

There is only Number in Access when designing a table. I saw no Integer or Long Integer.
@JasonStack You can choose between the various types of Number fields (Integer, Long Integer, Single, Double, ...) using the "Field Size" property in the lower pane of Design View for the table. The default for a Number field is Long Integer.
2

Bitness of your OS has nothing to do with the bitness of integer you want to store. It only depends on the accepted range of integer values of your ComboBox elements. For all practical purposes, you should be good with converting to Int32.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.