.net的本机oracle提供程序不会将名称参数绑定作为默认值,因此您必须手动设置它。
但是,在以下代码中,未设置它,除非我替换行
DbConnection conn = factory.CreateConnection();
与
DbConnection conn = OracleClientFactory.Instance.CreateConnection();
以下是完整代码:
DbProviderFactory factory = DbProviderFactories.GetFactory("Oracle.DataAccess.Client");
DbConnection conn = factory.CreateConnection();
using(DbCommand command = conn.CreateCommand())
{
if( command is Oracle.DataAccess.Client )
{
((Oracle.DataAccess.Client.OracleCommand)command).BindByName = true;
}
}
为什么会这样?