Solved

Using CINT in a query

Posted on 2006-10-21
2
12,472 Views
Last Modified: 2008-03-03
Hi experts

My SQL query :

SQL = SQL & " AND ((cint(ShipOther1) <= " & ProdWeight & " AND " & ProdWeight & " <= cint(ShipOther2)) "
               SQL = SQL & " OR (ShipCost1 <= " & ProdWeight & " AND " & ProdWeight & " <= ShipCost2)) "

Returns an error:

Microsoft OLE DB Provider for ODBC Drivers erreur '80040e14'

(Microsoft}(ODBC SQL Server Driver}(SQL Server}'cint' is not a recognized function name.

/shopshippingcalc.asp, ligne 538

How can i fix this ?
Thx
0
Comment
Question by:humer2000
  • 2
2 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 17779948
CInt() is not a SQL Server function--it is an Access/VB/VBA function.

For SQL Server, use CAST or CONVERT:

CONVERT(data_type, expression, [optional format type])
CAST(expression AS data_type)

SQL = SQL & " AND ((CONVERT(int, ShipOther1) <= " & ProdWeight & _
    " AND " & ProdWeight & " <= CONVERT(int, ShipOther2)) OR (ShipCost1 <= " _
    & ProdWeight & " AND & ProdWeight & " <= ShipCost2)) "

You may also need to replace the & within the quotes to be + (SQL Server uses + as a string
concatenator).

Patrick
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17779964
Also be advised that the Integer data type for Access/VB/VBA is *not* the same as the
int data type in SQL Server.  SQL Server's int data type is analogous to the Access/VB/VBA
Long, and SQL Server's smallint data type is analogous to the Access/VB/VBA Integer.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now