我有这个代码处理收据的连续编号。输入收据号码时一切正常。最近我们接受了他们为我们公司处理付款的中心。他们的人数似乎很长。当输入时抛出“算术运算导致溢出”错误。我注意到只有当数字长度大于10时才会出现这种情况。
Dim input As String = InputBox("New ORNo", "Sequence No", ORNoTextBox.Text)
Try
For i = 0 To input.Length - 1
If IsNumeric(input.Chars(i)) = False Then
MsgBox("Please Input a Valid Sequence No", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid Input")
Exit Sub
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
If String.IsNullOrEmpty(input) Then
MsgBox("Please Input a Valid Sequence No", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid Input")
Exit Sub
End If
Dim integerInput As Double = Double.Parse(input.Trim)
Try
ORPaymentsDB.DBConnect("ConcessionairesAccnt")
integerInput -= 1
ORPaymentsDB.ExecuteSQL("Update Counter set SeqNo=@0 Where CCode=@1", integerInput, CounterCode)
Catch ex As Exception
ORPaymentsDB.rollback()
ORPaymentsDB.CloseDB()
MsgBox("Error Saving ORNo" & vbNewLine & ex.ToString, "Error...")
Exit Sub
Finally
End Try
我将我的数据库列从int更改为数字(18,0)并且它工作正常。
主要依靠布莱克伍德先生的评论
数据库中的序列号可能定义为32位整数。在这种情况下,它接受的最高值是2,147,483,647(有10位小数)。如果你想接受比这更高的数字,你的数据库将需要使用其他东西(可能是64位整数)