none
dataset throwing arithmetic exception RRS feed

  • Question

  • I have a function that is throwing an arithmetic exception when I try to store a 10 digit number. I checked the database, the field is set to bigint and I can enter the number manually without any problems. I also tested the stored procedure I use to insert the data and it too will accept the number without any problems.

    However, when I use the data table's add row method I get an arithmetic exception. The field in the dataset is set to System.Int64. 

    I am lost as to what may be causing this. Any help would be greatly appreciated.

    thanks,

    Luis

     

     

    Saturday, August 19, 2006 3:35 PM

Answers

All replies

  • Can you give the source code of your function which throws the exception and how you call it?
    Saturday, August 19, 2006 5:15 PM
  • Here is the source code I'm using. Basically I get a DirectoryInfo or FileInfo object and pass some of the values to a database table in memory

    Private Sub AddFileToExisting(ByVal Name As String, ByVal Length As Integer, ByVal CreationTime As Date, ByVal DirectoryName As String, ByVal Extension As String, ByVal FullName As String, ByVal IsReadOnly As Boolean, ByVal LastAccessTime As Date, ByVal LastWriteTime As Date, ByVal strParent As String, ByVal strFileType As String)

    Try

    If Me.CheckDate(CreationTime) And Me.CheckDate(LastAccessTime) And Me.CheckDate(LastWriteTime) Then

    frmMain.dtabExistingFiles.AddtblMasterFilesRow(Name, Length, CreationTime, DirectoryName, Extension, FullName, IsReadOnly, LastAccessTime, LastWriteTime, Date.Now, strFileType, strParent)

    Else

    If Me.CheckDate(CreationTime) = False Then

    CreationTime = CDate("1/1/1900")

    End If

    If Me.CheckDate(LastAccessTime) = False Then

    LastAccessTime = CDate("1/1/1900")

    End If

    If Me.CheckDate(LastWriteTime) = False Then

    LastWriteTime = CDate("1/1/1900")

    End If

    frmMain.dtabExistingFiles.AddtblMasterFilesRow(Name, Length, CreationTime, DirectoryName, Extension, FullName, IsReadOnly, LastAccessTime, LastWriteTime, Date.Now, strFileType, strParent)

    End If

    Public Function CheckDate(ByVal dateToCheck As DateTime) As Boolean

    Dim datMin As DateTime = CDate("1/1/1753")

    If datMin < dateToCheck And dateToCheck < DateTime.MaxValue Then

    Return True

    Else

    Return False

    End If

    End Function

    Catch sqlEx As SqlClient.SqlException

    Catch ex As Exception

    If ex.Message.ToString.Contains("Cannot set column 'Extension'") Then

    Extension = "UNK"

    frmMain.dtabExistingFiles.AddtblMasterFilesRow(Name, Length, CreationTime, DirectoryName, Extension, FullName, IsReadOnly, LastAccessTime, LastWriteTime, Date.Now, strFileType, strParent)

    Else

    Throw ex

    End If

    End Try

    End Sub

    Saturday, August 19, 2006 7:30 PM
  • From your code, I didn't see anything related to int64...
    Monday, August 21, 2006 5:58 PM