简体   繁体   中英

Replacing TableAdapters with Oracle.DataAccess.Client (ODP.NET)

I have a legacy DAL with like 100 TableAdapters (DataSet xsd) but because we got new servers with Oracle client 12c I had to made the switch to the Oracle.DataAccess.Client (ODP.NET) from the old deprecated System.Data.OracleClient .

The only problem I have now is that I always get an error: ORA-01008: Not all variables bound when calling the Table Adapters.

I read that I have to set BindByName to true in OracleCommand for each TableAdapter. But how can I do that when the only place where OracleCommand is used is in the designer of the TableAdapter itself?

Is there some way to do this without extending each TableAdapter, because I have like 100 of them.

What I did was I extended each TableAdapter and created a new SetBindByName() method, where I forced BindByName = true on the OracleCommand collection.

Like so...

public partial class V_CUSTOMER_GLOBALTableAdapter
{
    public void SetBindByName(bool value = true)
    {
        foreach (Oracle.DataAccess.Client.OracleCommand cmd in this.CommandCollection)
        {
            cmd.BindByName = value;
        }
    }
}

Then when I created an instance of the TableAdapter, I called the new SetBindByName() method.

V_CUSTOMER_GLOBALTableAdapter ta = new V_CUSTOMER_GLOBALTableAdapter();
ta.SetBindByName(true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM