[Mono-dev] Problem with parameters using Odbc/ADO.NET/Sybase 9.0.2 ASA

Mads Bondo Dydensborg mbd at dbc.dk
Fri Dec 22 08:07:05 EST 2006


Hi there

I have a program using parameters for inserts using Odbc on a Linux platform 
against a Sybase ASA 9.0.2 server. I have tried to make a minimal program to 
illustrate the problem. It looks like the parameters are not substituted?

The program below fails with:

$ mono --debug MinTestOdbc.exe

Unhandled Exception: System.Data.Odbc.OdbcException: [Sybase][ODBC Driver]
[Adaptive Server Anywhere]Column '@p1' not found
  at System.Data.Odbc.OdbcCommand.ExecSQL (System.String sql) [0x000a2] 
in /home/madsdyd/xIntegra/MONOTRUNK/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs:414
  at System.Data.Odbc.OdbcCommand.ExecuteNonQuery (Boolean freeHandle) 
[0x0002a] 
in /home/madsdyd/xIntegra/MONOTRUNK/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs:440
  at System.Data.Odbc.OdbcCommand.ExecuteNonQuery () [0x00000] 
in /home/madsdyd/xIntegra/MONOTRUNK/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs:428
  at MinOdbcTest.Main (System.String[] args) [0x0004c] 
in /home/madsdyd/xIntegra/SybaseTest/Odbc/MinTestOdbc.cs:23

The Sybase server says :

** REQUEST conn: 33    STMT_PREPARE            "insert into mono_sql_test ( 
char_value ) values ( @p1 )"
** DONE    conn: 33    STMT_PREPARE            Stmt=65539
** REQUEST conn: 33    STMT_DESCRIBE_OUTPUT    Stmt=-1
** DONE    conn: 33    STMT_DESCRIBE_OUTPUT
** REQUEST conn: 33    STMT_DESCRIBE_INPUT     Stmt=-1
** DONE    conn: 33    STMT_DESCRIBE_INPUT
** REQUEST conn: 33    STMT_EXECUTE            Stmt=65539
** ERROR   conn: 33    code: -143 "Column '@p1' not found"

This is mono/mcs from current svn.

The program is this:

using System;
using System.Data;
using System.Data.Odbc;
using System.Text;

class MinOdbcTest {
  static void Main(string[] args) {

    OdbcConnection cnc = new OdbcConnection 
( "DSN=SybaseASA;UID=DBA;PWD=SQL" );
    cnc.Open();

    OdbcCommand insertCommand = cnc.CreateCommand();
    insertCommand.CommandText 
      = "insert into mono_sql_test ( char_value ) values ( @p1 )";
  
    OdbcParameterCollection parameters = insertCommand.Parameters;
  
    parameters.Add ( "@p1", OdbcType.Char );
    parameters [ "@p1" ].Value = "This is a char";
    
    insertCommand.ExecuteNonQuery ();

    cnc.Close();
  }
}

Any help appreciated.

Regards,

Mads

-- 
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77 34




More information about the Mono-devel-list mailing list