请教大家,在使用DataSet删除一条记录时报出ORA-01036: 非法的变量名/编号,程序附后,辛苦大家看一下
我用如下方式在Oracle数据库中创建的表
create table test(
col1 char(10),
col2 int,
primary key(col1))
insert into test values( 'aaa ',1);
insert into test values( 'bbb ',2);
insert into test values( 'ccc ',3);
insert into test values( 'ddd ',4);
commit
然后用如下语句去执行删除
static void Delete()
{
OracleConnection conn = new OracleConnection( "Server=fzjclk_192.168.51.12;Password=fzjc;User ID=fzjc ");
OracleDataAdapter adp = new OracleDataAdapter();
DataSet ds = new DataSet();
try
{
OracleCommand cmd = new OracleCommand( "select * from test ", conn);
adp.SelectCommand = cmd;
OracleCommand deleteCmd = new OracleCommand( "delete from test where col1=? ", conn);
deleteCmd.Parameters.Add( "col1 ", OracleType.Char, 10, "col1 ");
adp.DeleteCommand = deleteCmd;
adp.Fill(ds, "test ");
DataTable table = ds.Tables[ "test "];
DataRow row = table.Rows[0];
row.Delete();
adp.Update(ds, "test "); // 此行报错
table.AcceptChanges();
ds.AcceptChanges();
Console.WriteLine( "deleted ");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
if (conn != null) conn.Close();
}
}
执行后输出:
System.Data.OracleClient.OracleException: ORA-01036: 非法的变量名/编号
在 System.Data.Commo