The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

I think I found a bug in ADO.NET driver for SA 11.

if I try to execute this code:

DbCommand command = connection.CreateCommand();
command.CommandText = "select 'my ' + 'string' from DUMMY";
string result = (string)command.ExecuteScalar();

Works fine. But if I change to use parameters, I get this error:

"iAnywhere.Data.SQLAnywhere.SAException: Cannot convert 'my string' to a int at iAnywhere.Data.SQLAnywhere.SACommand._ExecuteReader(CommandBehavior commandBehavior, Boolean isExecuteScalar, Boolean isBeginExecuteReader) at iAnywhere.Data.SQLAnywhere.SACommand.ExecuteScalar() "

In Interactive SQL, this command executes fine. If I change sql command to "select 'my ' || 'string' from DUMMY', ADO.NET executes fine too.

It's an bug or an expected behavor?

I'm using sa

asked 17 Dec '09, 14:00

Zote's gravatar image

accept rate: 43%

edited 05 Jan '10, 18:23

permanent link

answered 10 Jan '10, 19:17

Zote's gravatar image

accept rate: 43%

I copied/pasted your code into a VS2008 project and the last line gives the error:

Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)

So if I do either of:

string result = (string)command.ExecuteScalar();


string result = command.ExecuteScalar().ToString();

Then I get the correct result. Is this what you expected? I'm using SA


permanent link

answered 04 Jan '10, 21:23

Jos%C3%A9%20Ramos's gravatar image

José Ramos
accept rate: 30%

sorry, i'll correct above code. I'm working like your first option.

(05 Jan '10, 03:02) Zote

Whats your SA version ?

(05 Jan '10, 03:03) Zote

He said "I'm using SA"... what is your version?

(05 Jan '10, 07:26) Breck Carter

Sorry, it's my fault :( I'm using I'll update it and test again.

(05 Jan '10, 10:31) Zote

+1 fault mine. Using above sql command, it works fine. But using parameters (and its my real case) it crashes.

(05 Jan '10, 18:21) Zote

Try starting a new question, with exact code and exact versions of everything and exact error message if possible... sometimes a reboot helps :)

(05 Jan '10, 21:41) Breck Carter

Nice tip! Tomorrow I'll, I'm at home now.

(05 Jan '10, 23:33) Zote
More comments hidden
showing 5 of 8 show all flat view
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 17 Dec '09, 14:00

question was seen: 1,124 times

last updated: 10 Jan '10, 19:17