Question

I'm trying to issue a parameterised SELECT to an Interbase XE database using ADO.NET. The code I'm using is as follows:

using (OdbcConnection odbcConnection = new OdbcConnection(ConfigurationManager.ConnectionStrings["LawbaseTest"].ToString()))
      {
        odbcConnection.Open();
        using (OdbcCommand odbcCommand = new OdbcCommand())
        {
          odbcCommand.CommandType = CommandType.Text;
          odbcCommand.Connection = odbcConnection;
          odbcCommand.Parameters.Add(new OdbcParameter(":CaseNumber", 1265));
          odbcCommand.CommandText = "select * from cmstub where cm_recnum = :CaseNumber";
          using (IDataReader rdrData = odbcCommand.ExecuteReader())
          {
            Output(rdrData["CM_DESC"]);
          }
        }
      }

I'm getting the following error:

ERROR [42S22] [DataDirect][ODBC InterBase driver][InterBase]Dynamic SQL Error, SQL error code = -206, Column unknown, CASENUMBER

Which suggests to me that the query is not being sent to Interbase in a syntax it recognises as a parameterised query.

This is rather harder than I was expecting. Am I being a ficko? Can you help?

Was it helpful?

Solution

It seems to be the norm that named parameters aren't supported widely, did you try using ? instead, i.e. cm_recnum = :CaseNumber to cm_recnum = ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top