C#InvalidOperationException“对于不返回任何键列信息的SelectCommand,不支持UpdateCommand的动态SQL生成”在打电话给... [英] C# InvalidOperationException "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information" when calling the...
问题描述
您好,
当我调用OracleDataAdapter Update方法时,我遇到了InvalidOperationException:adapter.Update(userTable) );。
我有一个OracleDataAdapter命名适配器,一个名为ds的DataSet,一个名为userTable的DataTable
我在queryString中使用2个相关表:
Hello,
I've got an InvalidOperationException when I call the the OracleDataAdapter Update method : "adapter.Update(userTable);".
I've got an OracleDataAdapter named adapter, a DataSet named ds, a DataTable named userTable
I use 2 related tables in my queryString :
select i.num_int_int as "Numéro interne",
i.nom_log as "Login",
i.psw_web as "Password",
i.lib_int as "Libellé User",
u.cod_usp as "Profil",
i.cod_soc as "Société",
i.flg_out as "OUT"
from tab_inte i, tab_usty u
where i.nom_log is not null and
i.psw_web is not null and
(i.flg_out <> 'O' or i.flg_out is null or i.flg_out = 'N')
and i.num_int_int = u.num_int_int
and i.cod_soc = u.cod_soc
order by i.num_int_int
我有以下错误对于一个不返回任何键列信息的SelectCommand,不支持UpdateCommand的动态SQL生成
I've got the following error "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information" after
adapter.Fill(ds);
userTable = ds.Tables[0];
adapter.Update(userTable);
如果我将queryString更改为单个表选择,我没有更多错误:
queryString:
If I Change my queryString to a single table select, I've got no more error:
queryString :
select num_int_int as "Numéro interne",
nom_log as "Login",
psw_web as "Password",
lib_int as "Libellé User",
cod_soc as "Société",
flg_out as "OUT"
from tab_inte
where nom_log is not null and
psw_web is not null and
(flg_out <> 'O' or flg_out is null or flg_out = 'N' )
order by num_int_int
关于如何解决这个问题的想法?
PS:这不是SQL问题,因为查询在SQL +和Toad for Oracle中运行良好。
PS2:table tab_inte(别名i)有一个简单的主键:i.num_int_int
表tab_usty(别名u)有一个复合主键:(u.num_int_int,u.cod_usp)
Best问候,
Tek001
Any idea on how to resolve this issue?
PS : This not an SQL issue, because the query works fine in SQL+ and Toad for Oracle.
PS2: table tab_inte (alias i) has a simple primary key : i.num_int_int
table tab_usty (alias u) has a composite primary key : (u.num_int_int,u.cod_usp)
Best regards,
Tek001
推荐答案
我在这里推测,但我想如果你想从多个表中选择信息,你需要加入他们。
所以你这样做了:
I'm speculating here, but I thought that if you wanted to select information from multiple tables you need to join them.
So were you have done this:
from tab_inte i, tab_usty u
你应该做的事情如下:
You should be doing something like:
from tab_inte i join tab_usty u on u.inteId = i.id
(不知道你的表结构以及它们是如何相关的我完全猜测你的列名和表是如何相关的。)
(without knowing your table structure and how they are related I am completely guessing on the name of your columns and how the tables are related.)
尝试更新.net oracle连接器。也许是一个错误。
Try updating your .net oracle connector. Maybe a bug in it.
这篇关于C#InvalidOperationException“对于不返回任何键列信息的SelectCommand,不支持UpdateCommand的动态SQL生成”在打电话给...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!