Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

Version have a new BUG in .NET driver.

If you try to execute a sql with string parameter it's throws an exception Not enough values for host variables.

It works fine using int parameters. Didn't try with another types.

Here is a sample application.

class Program
    static void Main(string[] args)
        var factory = DbProviderFactories.GetFactory("iAnywhere.Data.SQLAnywhere");

using (var connection = factory.CreateConnection())
            connection.ConnectionString = "my connection string";

                using (var command = connection.CreateCommand())
                    command.CommandText = "select count(*) from DUMMY where (dummy_col = ?)";
                    command.Parameters[0].Value = 1;

Console.WriteLine("[Int] {0} records found.", command.ExecuteScalar());
            catch (Exception ex)
                Console.WriteLine("Int Exception: {0}", ex.Message);

                using (var command = connection.CreateCommand())
                    command.CommandText = "select count(*) from DUMMY where (cast(dummy_col as varchar(10)) = ?)";
                    command.Parameters[0].Value = "1";

Console.WriteLine("[String] {0} records found.", command.ExecuteScalar());
            catch (Exception ex)
                Console.WriteLine("String Exception: {0}", ex.Message);


WORKAROUND use build 2427

asked 03 Aug '10, 19:32

Zote's gravatar image

accept rate: 43%

edited 04 Aug '10, 18:33

You should post this to the official newsgroup or use the following way:

How do I report a bug?

Log in to

Bugs reported using Case-Express are assigned a lower priority than cases opened through Technical Support. For priority issues, open a support case with Technical Support (

by the way, with it works ok.

permanent link

answered 09 Aug '10, 08:03

Martin's gravatar image

accept rate: 14%


I've tested using Visual Studio 2005 / 2008 / 2010 for all .NET Framework versions ( 2.0 / 3.0 / 3.5 / 3.5 Client Profile / 4.0 / 4.0 Client Profile ), but I was not able to reproduce this problem. We have testing code which covers this scenario. We've never seen this problem.

I don't know why you got this error. It's probably caused by some version problems. I would suggest reinstall SQL Anywhere and check the GAC and machine.config.

permanent link

answered 11 Aug '10, 16:56

Minghai%20Chang%201's gravatar image

Minghai Chang 1
accept rate: 0%

I did it in my machine, in a fresh new virtual machine and at a co-worker machine...

(11 Aug '10, 19:13) Zote
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: 03 Aug '10, 19:32

question was seen: 2,353 times

last updated: 11 Aug '10, 16:56