Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
How to insert data into tables of oracle from C# windows application
Posted

 
Share this answer
 
v2
Comments
anilkumar.6714 21-May-12 6:56am    
Thank you..
Shahin Khorshidnia 21-May-12 6:59am    
You're welcome
Mohamed Mitwalli 21-May-12 8:27am    
5+
Shahin Khorshidnia 22-May-12 0:01am    
Thank you very much Mohammad!
anilkumar.6714 1-Jun-12 11:39am    
Thank you
 
Share this answer
 
Comments
anilkumar.6714 21-May-12 7:08am    
Thank you..
Mohamed Mitwalli 21-May-12 7:26am    
Your welcome :)
VJ Reddy 22-May-12 23:09pm    
Good references. 5!
Mohamed Mitwalli 23-May-12 3:25am    
Thanks VJ :)
anilkumar.6714 1-Jun-12 11:39am    
Thank you
Try this:

Add the following C# using statements before the Public Class declaration.
C#
using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
using Oracle.DataAccess.Types;


Add the following C# code in between the
C#
private void button1_Click(object sender, EventArgs e)

{ and } statements.

C#
string oradb = "Data Source=ORCL;User Id=hr;Password=hr;";

OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into Table1('Name') VALUES(txtName.text) WHERE id = 1"; 
Int rowsUpdated = cmd.ExecuteNonQuery(); 
If (rowsUpdated == 0) 
 MessageBox.Show("Record not inserted"); 
Else 
 MessageBox.Show("Success!"); 
conn.Dispose();


Hope it helps!
 
Share this answer
 
Comments
Mohamed Mitwalli 21-May-12 8:27am    
5+
Prasad_Kulkarni 21-May-12 8:28am    
Thank you Mohamed!
tetoeko 17-Dec-12 4:00am    
i already use this, and it work. then i try to integrate the code with wcf msmq. when the service get the data from client, it save the data to oracle db immediately. but then the error happened, the notification is "ORA-24434: OCIStmtRelease called before OCIStmtPrepare2.". i don't know how to fix it. if someone understand this problem, please reply to my comment. thanks and also i'm sorry if my question is quite out of topic.

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