insert oracle data,OracleDataAdapter

获取或设置用于将新记录插入到数据库中的 SQL 语句或存储过程。Gets or sets an SQL statement or stored procedure used to insert new records into the database.

public:

property System::Data::OracleClient::OracleCommand ^ InsertCommand { System::Data::OracleClient::OracleCommand ^ get(); void set(System::Data::OracleClient::OracleCommand ^ value); };

public System.Data.OracleClient.OracleCommand InsertCommand { get; set; }

member this.InsertCommand : System.Data.OracleClient.OracleCommand with get, set

Public Property InsertCommand As OracleCommand

属性值

OracleCommand,在更新操作中使用,用于将与 DataSet 中的新行对应的记录插入数据库。An OracleCommand used during an update operation to insert records in the database that correspond to new rows in the DataSet.

示例

The following example creates an OracleDataAdapter and sets the SelectCommand and InsertCommand properties. It assumes you have already created an OracleConnection object.

Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter

Dim da As OracleDataAdapter = New OracleDataAdapter()

Dim cmd As OracleCommand

' Create the SelectCommand.

cmd = New OracleCommand("SELECT * FROM Dept " & _

"WHERE DName = :pDName AND Loc = :pLoc", conn)

cmd.Parameters.Add("pDName", OracleType.NVarChar, 14)

cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13)

da.SelectCommand = cmd

' Create the InsertCommand.

cmd = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _

"VALUES (:pDeptNo, :pDName)", conn)

cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo")

cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName")

da.InsertCommand = cmd

Return da

End Function

public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn)

{

OracleDataAdapter da = new OracleDataAdapter();

OracleCommand cmd;

// Create the SelectCommand.

cmd = new OracleCommand("SELECT * FROM Dept " +

"WHERE DName = :pDName AND Loc = :pLoc", conn);

cmd.Parameters.Add("pDName", OracleType.NVarChar, 14);

cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13);

da.SelectCommand = cmd;

// Create the InsertCommand.

cmd = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " +

"VALUES (:pDeptNo, :pDName)", conn);

cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo");

cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName");

da.InsertCommand = cmd;

return da;

}

注解

When the InsertCommand property is assigned to a previously created OracleCommand object, the OracleCommand is not cloned. Instead, InsertCommand maintains a reference to the previously created OracleCommand.

During an update operation, if InsertCommand is not set and primary key information is present in the DataSet, you can use the OracleCommandBuilder class to automatically generate InsertCommand, and additional commands needed to reconcile the DataSet to the database. To do this, set the SelectCommand property of the OracleDataAdapter. 生成逻辑还要求中存在键列信息 DataSet 。The generation logic also requires key column information to be present in the DataSet.

备注

如果执行此命令将返回行,则可能会 DataSet 根据设置对象的属性的方式将这些行添加到中 UpdatedRowSource OracleCommand 。If execution of this command returns rows, these rows may be added to the DataSet depending upon how you set the UpdatedRowSource property of the OracleCommand object.

当您更新数据类型为的列时 LONG RAW ,当您 NULL 在列中输入值时,将引发异常。When you update a column with the LONG RAW data type, an exception is thrown when you enter a value of NULL in the column. Oracle LONG RAW 数据类型是 oracle 版本8.0 中不推荐使用的类型。The Oracle LONG RAW data type is a deprecated type in Oracle version 8.0. 若要避免此错误,请使用 BLOB 数据类型而不是 LONG RAW 。To avoid this error, use the BLOB data type instead of LONG RAW.

适用于

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值