[英]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
. 我有一个带有100个TableAdapters(DataSet xsd)的旧版DAL,但是由于我们使用的是带有Oracle客户端12c的新服务器,因此不得不从旧的过时的
System.Data.OracleClient
切换到Oracle.DataAccess.Client
(ODP.NET)。 。
The only problem I have now is that I always get an error: ORA-01008: Not all variables bound when calling the Table Adapters. 我现在遇到的唯一问题是,我总是收到错误消息: ORA-01008:调用表适配器时, 并非所有变量都已绑定 。
I read that I have to set BindByName
to true
in OracleCommand
for each TableAdapter. 我读到我必须在每个表
BindByName
OracleCommand
中将BindByName
设置为true
。 But how can I do that when the only place where OracleCommand
is used is in the designer of the TableAdapter itself? 但是,当唯一使用
OracleCommand
地方是在TableAdapter本身的设计器中时,该怎么办?
Is there some way to do this without extending each TableAdapter, because I have like 100 of them. 有什么方法可以做到这一点而无需扩展每个TableAdapter,因为我喜欢其中的100个。
What I did was I extended each TableAdapter and created a new SetBindByName()
method, where I forced BindByName = true
on the OracleCommand collection. 我要做的就是扩展每个TableAdapter并创建一个新的
SetBindByName()
方法,在其中我在OracleCommand集合上强制BindByName = true
。
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. 然后,当我创建TableAdapter的实例时,我调用了新的
SetBindByName()
方法。
V_CUSTOMER_GLOBALTableAdapter ta = new V_CUSTOMER_GLOBALTableAdapter();
ta.SetBindByName(true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.