参数化查询未按预期工作。在c#中执行Informix ODBC命令时:
OdbcCommand oc = Connection.CreateCommand();
oc.CommandText = "SELECT COUNT(*) AS CNT, MAX(someattr) AS attr1 FROM ?";
oc.Parameters.Add(new OdbcParameter() { Value = table.Name, OdbcType = OdbcType.Char });
try
{
OdbcDataReader or = oc.ExecuteReader(); //here the exception occurs
....
发生异常:ERROR [42000] [Informix] [Informix ODBC Driver] [Informix]发生语法错误。
但以下代码无例外地工作
OdbcCommand oc = Connection.CreateCommand();
oc.CommandText = String.Format("SELECT COUNT(*) AS CNT, MAX(someattr) AS attr1 FROM {0}", table.Name);
try
{
OdbcDataReader or = oc.ExecuteReader();
...
参数化查询可能存在什么问题? :/