Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Version 11.0.1.2467 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";
            connection.Open();

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

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

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

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

Console.ReadLine();
    }
}

WORKAROUND use build 2427

asked 03 Aug '10, 19:32

Zote's gravatar image

Zote
1.7k364051
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 http://case-express.sybase.com.

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 (http://www.sybase.com/support).

by the way, with 11.0.1.2452 it works ok.

permanent link

answered 09 Aug '10, 08:03

Martin's gravatar image

Martin
9.0k130169257
accept rate: 14%

Hi,

I've tested 11.0.1.2467 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
111
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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×143
×43

question asked: 03 Aug '10, 19:32

question was seen: 2,228 times

last updated: 11 Aug '10, 16:56