Louis Kenney

Louis Kenney

  • NA
  • 11
  • 0

SqlParameter Int64/Int32 conversion

Mar 15 2008 10:10 AM

Hi,

I have the following lines of code in my application.

SqlParameter para = _mySqlCommand.Parameters.Add("documentId", SqlDbTypes.Int, 0);

para.Value = documentId

documentId is a long (Int64), in the database the DocumentId column is an Int.

When I try and pass the maximum value of an Int64 I get a conversion error as SqlParameter tries to convert it to an Int32.

The StackTrace is

System.Convert.ToInt32(Int64 value)
   at System.Int64.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType)

What have I done wrong?

Thanks

Louis


Answers (1)