Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an data table and it contains a row and one column ID type of int.
And the table in oracle databse has a column named ID with numeric datatype.

the code is as below.

C#
cmd.Connection = oracleCon;
cmd.CommandText = @"INSERT INTO Name(ID) VALUES(:p1)";
cmd.Parameters.Add(":p1", "1236");
cmd.ExecuteNonQuery();
this works fine.

but if i change the code or when i try to insert the value from the datatable as like below

C#
cmd.Connection = oracleCon;
cmd.CommandText = @"INSERT INTO Name(ID) VALUES(:p1)";
cmd.Parameters.Add(":p1", row["ID"]);
cmd.ExecuteNonQuery();

it does not work. the system hangs after executenonquery.

but if i make it
C#
cmd.Parameters.Add(":p1", Convert.ToInt32(row["ID"]));


then system hangs.

Can any one help me out of this.

Thanks
PP
Posted
Updated 31-Aug-13 0:48am
v6
Comments
Dave963 31-Aug-13 5:29am    
Did you try this cmd.Parameters.Add(":p1", row["ID"].ToString());
PP from bangalore 31-Aug-13 5:58am    
Hi Dave

I have updated the question but after trying that i get the same thing like the system hangs.

1 solution

And again the problem was that when i was deleting from the database as it is an oracle database i was not commiting from the oracle database.So the system was not responding.
Any way things aer now working fine.
 
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