Home All Groups Group Topic Archive Search About

SQL Execution Error: Cannot call methods on int

Author
2 Dec 2005 11:03 AM
rask
I have run in to the following problem on MS SQL Server 2005: When I
attempt to execute the following query in SQL Server Management Studio
or Visual Studio 2005 Database project an exception is thrown.

SELECT     CAST('2' AS INTEGER) AS Expr1

The error message says:

---------------------------
Microsoft SQL Server Management Studio
---------------------------
SQL Execution Error.

Executed SQL statement: SELECT CAST('2' AS INTEGER).ToString() AS Expr1
Error Source: .Net SqlClient Data Provider
Error Message: Cannot call methods on int.
---------------------------
OK   Help
---------------------------

The funny thing is that if I open up good old SQL Query Analyzer it can
execute it without any problems.

The following query executes without any problem on Management Studio:

SELECT     CAST('2' AS DECIMAL) AS Expr1

So it does seem like the problem is in the .Net SqlClient Data
Provider, but how to fix it? Any ideas? Thanks!

Author
3 Dec 2005 4:56 PM
Erland Sommarskog
(r***@rsktech.com) writes:
Show quote
> I have run in to the following problem on MS SQL Server 2005: When I
> attempt to execute the following query in SQL Server Management Studio
> or Visual Studio 2005 Database project an exception is thrown.
>
> SELECT     CAST('2' AS INTEGER) AS Expr1
>
> The error message says:
>
> ---------------------------
> Microsoft SQL Server Management Studio
> ---------------------------
> SQL Execution Error.
>
> Executed SQL statement: SELECT CAST('2' AS INTEGER).ToString() AS Expr1
> Error Source: .Net SqlClient Data Provider
> Error Message: Cannot call methods on int.

Funky. I was not able to repeat this. (I tried Mangement Studio only).
Are you running this from the Query Editor?


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
3 Dec 2005 5:02 PM
Steve Kass
I can repro this in the View Designer.  Surely it's a bug, and I'll
report it.

Steve Kass
Drew University

r***@rsktech.com wrote:

Show quote
>I have run in to the following problem on MS SQL Server 2005: When I
>attempt to execute the following query in SQL Server Management Studio
>or Visual Studio 2005 Database project an exception is thrown.
>
>SELECT     CAST('2' AS INTEGER) AS Expr1
>
>The error message says:
>
>---------------------------
>Microsoft SQL Server Management Studio
>---------------------------
>SQL Execution Error.
>
>Executed SQL statement: SELECT CAST('2' AS INTEGER).ToString() AS Expr1
>Error Source: .Net SqlClient Data Provider
>Error Message: Cannot call methods on int.
>---------------------------
>OK   Help
>---------------------------
>
>The funny thing is that if I open up good old SQL Query Analyzer it can
>execute it without any problems.
>
>The following query executes without any problem on Management Studio:
>
>SELECT     CAST('2' AS DECIMAL) AS Expr1
>
>So it does seem like the problem is in the .Net SqlClient Data
>Provider, but how to fix it? Any ideas? Thanks!
>

>
Author
3 Dec 2005 5:06 PM
Steve Kass
A workaround is to name the data type INT instead of INTEGER.

SK

r***@rsktech.com wrote:

Show quote
>I have run in to the following problem on MS SQL Server 2005: When I
>attempt to execute the following query in SQL Server Management Studio
>or Visual Studio 2005 Database project an exception is thrown.
>
>SELECT     CAST('2' AS INTEGER) AS Expr1
>
>The error message says:
>
>---------------------------
>Microsoft SQL Server Management Studio
>---------------------------
>SQL Execution Error.
>
>Executed SQL statement: SELECT CAST('2' AS INTEGER).ToString() AS Expr1
>Error Source: .Net SqlClient Data Provider
>Error Message: Cannot call methods on int.
>---------------------------
>OK   Help
>---------------------------
>
>The funny thing is that if I open up good old SQL Query Analyzer it can
>execute it without any problems.
>
>The following query executes without any problem on Management Studio:
>
>SELECT     CAST('2' AS DECIMAL) AS Expr1
>
>So it does seem like the problem is in the .Net SqlClient Data
>Provider, but how to fix it? Any ideas? Thanks!
>

>

AddThis Social Bookmark Button