Reputation: 571
This is for a website in C#,Visual Studio 2010.
I've created a form with many textboxes, a date picker, dropdownlist, etc. I've created a table in sqlplus with the columns with necessary types(varchar, number, date). When I click the submit button in my form, I want to store the data in the table I've created.
Just to make it simpler for you guys, assume I have 3 text boxes (name(text), id, date(i've printed the date in the text box as string)).
When I click submit it should fill the table with these data. Im struggling to get the OracleCommand to execute this.
cmd = new OracleCommand(______, con);
If there is any other way I can do this by manipulating the types also its welcome :)
Upvotes: 0
Views: 116
Reputation: 9361
The insert syntax for oracle commands generally follows the pattern;
string query = @"INSERT INTO SOME_TABLE VALUES (SOME_COLUMN_1 = :SomeParam1,SOME_COLUMN_2 = :SomeParam2 )";
OracleCommand command = new OracleCommand(query, connection) { CommandType = CommandType.Text };
command.Parameters.Add(":SomeParam1", OracleDbType.Varchar2).Value = "Your Val 1";
command.Parameters.Add(":SomeParam2", OracleDbType.Varchar2).Value = "Your Val 2";
connection.ExecuteNonQuery();
See more reference examples here; Using Named Parameters with Oracle ODP.NET
Upvotes: 2