G
Guest
Hi,
I am new to column mappings and can't seem to make them work. The following
is an example:
DataTable table = new DataTable( "SYSTEM.Usernames");
table.Columns.Add( "S1", typeof(decimal) );
OracleCommand cmd = new OracleCommand();
cmd.Connection = this.oracleConnection1;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT SuperUserFlag FROM SYSTEM.Usernames WHERE
Username = 'JuanDent'";
OracleDataAdapter da = new OracleDataAdapter( cmd );
DataSet ds = new DataSet( "Temp ds");
ds.Tables.Add( table );
DataTableMapping map = da.TableMappings.Add( "Table", table.TableName );
map.ColumnMappings.Add( "S1", "SuperUserFlag" );
ds.EnforceConstraints = false;
da.MissingSchemaAction = MissingSchemaAction.Error;
try
{
da.Fill( ds, 0, 200, table.TableName );
}
catch( Exception ex )
{
MessageBox.Show( ex.Message, ex.Source);
}
No matter how I play with it, I can't get the Fill statement to work, it
always asks for a missing column "SuperUserFlag" in the table - I thought
this is precisely what column mappings did for us...
I am new to column mappings and can't seem to make them work. The following
is an example:
DataTable table = new DataTable( "SYSTEM.Usernames");
table.Columns.Add( "S1", typeof(decimal) );
OracleCommand cmd = new OracleCommand();
cmd.Connection = this.oracleConnection1;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT SuperUserFlag FROM SYSTEM.Usernames WHERE
Username = 'JuanDent'";
OracleDataAdapter da = new OracleDataAdapter( cmd );
DataSet ds = new DataSet( "Temp ds");
ds.Tables.Add( table );
DataTableMapping map = da.TableMappings.Add( "Table", table.TableName );
map.ColumnMappings.Add( "S1", "SuperUserFlag" );
ds.EnforceConstraints = false;
da.MissingSchemaAction = MissingSchemaAction.Error;
try
{
da.Fill( ds, 0, 200, table.TableName );
}
catch( Exception ex )
{
MessageBox.Show( ex.Message, ex.Source);
}
No matter how I play with it, I can't get the Fill statement to work, it
always asks for a missing column "SuperUserFlag" in the table - I thought
this is precisely what column mappings did for us...