Bug with TableAdapter Code generation
485900Jun 7 2006 — edited Jul 21 2006I believe I found a bug with the ODP.NET beta adapter.
I am using VS2005, C#.
When calling a stored procedure a refcursor must be returned in order to return a result set. If you set the select command of a table adapter to a stored procedure and add an out parameter and mark it as a RefObject. The auto generated code lookes like this:
private void InitCommandCollection() {
this._commandCollection = new Oracle.DataAccess.Client.OracleCommand[1];
this._commandCollection[0] = new Oracle.DataAccess.Client.OracleCommand();
this._commandCollection[0].Connection = this.Connection;
this._commandCollection[0].CommandText = "SPC_USERS_LIST";
this._commandCollection[0].CommandType = System.Data.CommandType.StoredProcedure;
Oracle.DataAccess.Client.OracleParameter param = new Oracle.DataAccess.Client.OracleParameter();
param.ParameterName = "BITSHOWALL";
param.DbType = System.Data.DbType.Byte;
param.Size = 22;
param.IsNullable = true;
param.SourceColumn = null;
this._commandCollection[0].Parameters.Add(param);
param = new Oracle.DataAccess.Client.OracleParameter();
param.ParameterName = "RCT1";
param.DbType = System.Data.DbType.Object;
param.Direction = System.Data.ParameterDirection.Output;
param.IsNullable = true;
param.SourceColumn = null;
this._commandCollection[0].Parameters.Add(param);
}
When you call Fill you get a bind error from Oracle.
What the code needs to be is this:
private void InitCommandCollection() {
this._commandCollection = new Oracle.DataAccess.Client.OracleCommand[1];
this._commandCollection[0] = new Oracle.DataAccess.Client.OracleCommand();
this._commandCollection[0].Connection = this.Connection;
this._commandCollection[0].CommandText = "SPC_USERS_LIST";
this._commandCollection[0].CommandType = System.Data.CommandType.StoredProcedure;
Oracle.DataAccess.Client.OracleParameter param = new Oracle.DataAccess.Client.OracleParameter();
param.ParameterName = "BITSHOWALL";
param.DbType = System.Data.DbType.Byte;
param.Size = 22;
param.IsNullable = true;
param.SourceColumn = null;
this._commandCollection[0].Parameters.Add(param);
param = new Oracle.DataAccess.Client.OracleParameter();
param.ParameterName = "RCT1";
param.OracleDbType = Oracle.DataAccess.Client.OracleDbType.RefCursor;
param.Direction = System.Data.ParameterDirection.Output;
param.IsNullable = true;
param.SourceColumn = null;
this._commandCollection[0].Parameters.Add(param);
}