ORA-00936:missing expression
-
I have a textbox called "textBox6.text" in a C# Windows Application in Visual Studio, and i want that the text entered by the user in the textbox should be added to the "PURPOSE" field in a table "TABLE2_HDB1" in Oracle database "HDB1" on clicking a "submit" button. the coding for submit button is as follows:- private void button1_Click(object sender, EventArgs e) { string OracleStmt; string ConString; OleDbConnection cn = null; OleDbCommand cmd = null; try { OracleStmt = "insert into TABLE2_HDB1(PURPOSE) values(@PURPOSE)"; ConString = " Provider=MSDAORA;Data Source=HDb1;User Id=SYSTEM ;Password=*****;"; cn = new OleDbConnection(ConString); cmd = new OleDbCommand(OracleStmt, cn); cmd.Parameters.Add(new OleDbParameter("@PURPOSE", OleDbType.VarChar , 20)); cmd.Parameters["@PURPOSE"].Value = textBox6.Text; cn.Open(); cmd.ExecuteNonQuery(); textBox8 .Text = "record inserted successfully"; } catch (Exception ex) { textBox8 .Text = ex.Message; } finally { cn.Close(); } } on executing this code u get the error :- ORA-00936:missing expression plz. help :~
-
I have a textbox called "textBox6.text" in a C# Windows Application in Visual Studio, and i want that the text entered by the user in the textbox should be added to the "PURPOSE" field in a table "TABLE2_HDB1" in Oracle database "HDB1" on clicking a "submit" button. the coding for submit button is as follows:- private void button1_Click(object sender, EventArgs e) { string OracleStmt; string ConString; OleDbConnection cn = null; OleDbCommand cmd = null; try { OracleStmt = "insert into TABLE2_HDB1(PURPOSE) values(@PURPOSE)"; ConString = " Provider=MSDAORA;Data Source=HDb1;User Id=SYSTEM ;Password=*****;"; cn = new OleDbConnection(ConString); cmd = new OleDbCommand(OracleStmt, cn); cmd.Parameters.Add(new OleDbParameter("@PURPOSE", OleDbType.VarChar , 20)); cmd.Parameters["@PURPOSE"].Value = textBox6.Text; cn.Open(); cmd.ExecuteNonQuery(); textBox8 .Text = "record inserted successfully"; } catch (Exception ex) { textBox8 .Text = ex.Message; } finally { cn.Close(); } } on executing this code u get the error :- ORA-00936:missing expression plz. help :~
Try to use : instead of @. So in your example it would be like:
OracleStmt = "insert into TABLE2_HDB1 (PURPOSE) values(:PURPOSE)";
...
cmd.Parameters.Add(new OleDbParameter(":PURPOSE", OleDbType.VarChar , 20));
cmd.Parameters[":PURPOSE"].Value = textBox6.Text;I'm not sure that if this correct when using OleDBConnection, but it works with native OracleConnection Mika