[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • Last Modified:

Arithmetic overflow error converting expression to data type int

I am getting the following error below:

Microsoft OLE DB Provider for SQL Server error '80040e57'
Arithmetic overflow error converting expression to data type int

It is connecting to a MSSQL database using ASP.

strsqlCFG1 = "SELECT TOP 5 tblCustomers.*,tblCustomers.CustID AS CustKey FROM tblCusomers WHERE  tblCustomers.Active='Active' ORDER BY RAND(-(1000*CustID)* " & R & ")"

The error goes away when I remove:
ORDER BY RAND(-(1000*CustID)* " & R & ")"

Any ideas?
0
JuniorBee
Asked:
JuniorBee
  • 2
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Reduce the 1000 to 100 or 10.  An integer value can be only so large and you're exceeding that.
0
 
JuniorBeeAuthor Commented:
Thanks !
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Integer data types max out at a little over 2 billion (4 billion possible numbers, 2 billion positive, 2 billion negative).  Make sure whatever you multiply by will NEVER reach that point or you may have this problem randomly again in the future.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now