Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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 :
SQL
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



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

C#
adapter.Fill(ds);
userTable = ds.Tables[0];
adapter.Update(userTable);


If I Change my queryString to a single table select, I've got no more error:
queryString :
SQL
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


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
Posted
Updated 9-Sep-14 4:39am
v11
Comments
George Jonsson 4-Sep-14 12:12pm    
Not everyone speaks French, you know.
tek001 5-Sep-14 4:15am    
Ok, I'm sorry.
kbrandwijk 4-Sep-14 14:46pm    
This querystring would only work if myvalue2.ToString() is actually an equation sign, like = or <>. Is that true?
tek001 5-Sep-14 4:14am    
No actualy the SQL query works only if it contains a single table (second example) whatever the arithmetical sign is (<>, =). Using more than one table (2 in the first example) rises the InvalidOperationException!
ZurdoDev 4-Sep-14 16:48pm    
ingles, por favor

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:
SQL
from tab_inte i, tab_usty u 

You should be doing something like:

SQL
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.)
 
Share this answer
 
Comments
tek001 5-Sep-14 4:27am    
the 2 tables are already joined :
and i.num_int_int = u.num_int_int
and i.cod_soc = u.cod_soc

=> this is not an SQL issue.
Pheonyx 5-Sep-14 4:36am    
Are you sure? I've never seen an SQL query that joins in the Where clause?

Just for a laugh, could you try changing the query to this:

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 join tab_usty u on i.num_int_int = u.num_int_int
and i.cod_soc = u.cod_soc
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')
order by i.num_int_int
[no name] 5-Sep-14 4:43am    
the query seem correct if the field that you use to join exist in both table kindly check if this query return any field maybe it return null also try this similar to Pheonyx one :
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 as i INNER JOIN tab_usty as u on i.num_int_int = u.num_int_int and i.cod_soc = u.cod_soc
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')
order by i.num_int_int
tek001 5-Sep-14 5:16am    
The 2 fields used to join the 2 tables exist in both of them. I’ve got the same error with your query. Sorry to insist but this is definitively not an SQL issue.
PS : Oracle does not accept "as" as table's alias. 575 records returned on Toad for Oracle
tek001 5-Sep-14 5:05am    
Yes, I'm sure.I'm working with oracle 11.2. Both querries give same result on Toad for Oracle (571 records) and i've got almost the same InvalidOperationException in C#:

"The Dynamic SQL code's generation Failed . No key information was found."

Best regards.
Tek001
Try updating your .net oracle connector. Maybe a bug in it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900