Jump to content

Generating Unique Integer using Format(Now, "ddMMyyhms") gives error

- - - - -

  • Please log in to reply
1 reply to this topic

#1
avosoft

avosoft

    Learning Programmer

  • Members
  • PipPipPip
  • 47 posts
Exception Details: System.OverflowException: Value was either too large or too small for an Int32.
Hello guys,
am trying to generate unique integer using the method shown, but it throws an exception. is there any other way i can generate this value that would be unique in every call?

Source Error: 


Line 27:         (Trim$(txtProductName.Text) <> vbNullString) And (Trim$(txtManufacturer.Text) <> vbNullString) And _

Line 28:         (Msds_file.HasFile <> False) And (Cert_file.HasFile <> False) Then

Line 29:             Dim ProductID As Integer = Convert.ToInt32(Format(Now, "ddMMyyhms"))

Line 30:             Dim sMsds As String = "M" & ProductID

Line 31:             Dim sCert As String = "C" & ProductID



Source File: J:\RAC\MSDS\main\admin\upload.aspx    Line: 29

Programming is all about good logic. Spend more time here

vHost for Apache:thumbup1:

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,822 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
ddMMyyhms is a 9 digit number that could be too large for a 32 bit int.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users