cancel
Showing results for 
Search instead for 
Did you mean: 

BUG In SA 11 .NET Driver

Former Member
0 Kudos
2,920

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 11.0.1.2355

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (1)

Answers (1)

Former Member

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();

-or-

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

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

José

Former Member
0 Kudos

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

Former Member
0 Kudos

Whats your SA version ?

Breck_Carter
Participant

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Breck_Carter
Participant
0 Kudos

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

Former Member
0 Kudos

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

Former Member