在对Oracle使用TableAdapter时如何设置BindByName? [英] How do you set BindByName when using TableAdapters against Oracle?

查看:73
本文介绍了在对Oracle使用TableAdapter时如何设置BindByName?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论好坏,我正在使用带有TableAdapters的DataSet来更新Oracle db表中的某些列。我的更新在update语句中使用了3次参数,我不断收到错误'ORA-01008:并非所有变量绑定'。我很确定我是否可以将BindByName设置为true,因为它将起作用。但是,我很难弄清楚如何在tableadapter中找到命令。



任何帮助都会受到赞赏。

For good or ill, I'm using DataSets with TableAdapters to update some columns in an Oracle db table. My update has is using a parameter 3 times in the update statement and I keep getting the error 'ORA-01008: not all variables bound'. I'm pretty sure if I can set the BindByName to true for the Command it will work. However, I am having a hard time figuring out how to get to the command in the tableadapter.

Any help would be appreciated.

推荐答案

当然,我会永远与之斗争,然后我发出一个问题,但不久后才发现答案。



我这样做是为了确保BindByName设置在所有内容上,但是如果您只想让其中一个命令设置BindByName,则可以编写更具体的项目。



表适配器具有部分类,因此您可以添加方法和属性以使生活更轻松。



Of course, I fight with this forever and then I send in a question, only to discover the answer myself shortly after.

I'm doing this to make sure the BindByName is set on everything, but more specific items can be written if you only want one of the commands to have the BindByName set.

The table adapters have partial classes so you can add methods and properties to make life easier.

namespace MyTableAdapters
{
    public partial class MyTabTableAdapter
    {
        public bool SetBindByName
        {
            set
            {
                this.Adapter.InsertCommand.BindByName = value;
                this.Adapter.UpdateCommand.BindByName = value;
                this.Adapter.DeleteCommand.BindByName = value;
                foreach (Oracle.DataAccess.Client.OracleCommand cmd in this.CommandCollection)
                {
                    cmd.BindByName = value;
                }
            }
        }
    }
}


这篇关于在对Oracle使用TableAdapter时如何设置BindByName?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆