Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert into Oracle Database using C#

992633Mar 8 2013 — edited Mar 8 2013
Hi Everyone,
I am trying to take data from text box and list box and then insert them to Oracle database:

Text box data:

Oracle = EMPLOYEE_NAME
C# = tbEmployeeName

List box data:

Oracle = EMPLOYEE_GENDER
C# = lbEmployeeGender


Here is my code in C#, can you guys help me with insert statement:


string oradb = "Data Source= oraDB;User Id=sm;Password=mypassword;";

OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "Insert into USER.EMPLOYEE VALUES (tbEmployeeName.Text, lbEmployeeGender.Text)";
int rowsUpdated = cmd.ExecuteNonQuery();
if (rowsUpdated == 0)
MessageBox.Show("Record not inserted");
else
MessageBox.Show("Success!");
conn.Dispose();



Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2013
Added on Mar 8 2013
1 comment
63,437 views