cfirex Posted November 27, 2007 Posted November 27, 2007 Hi folks, I've a dubt. If I use a query with named parameters like this : string query = "insert into test(name,age) values(:name,:age)" where name is a varchar2 and age is a number(3), If I do this : int age=29; string name="Phil"; OracleCommand myComm = new OracleCommand(sql, myConn); myComm.Parameters.Add("age", OracleDbType.Int32,ParameterDirection.Input); myComm.Parameters.Add("name", OracleDbType.Varchar2, ParameterDirection.Input); myComm.Parameters["age"].Value = age; myComm.Parameters["name"].Value = name; int rowsAffected = myComm.ExecuteNonQuery(); I get an error, because the order is wrong, and it tries to put the name in the number column :( . So, is the order the only way to associate the data column ??? :eek: Thank you :) P.S. : Oracle 9i and ODP.Net Quote
Eduardo Lorenzo Posted November 27, 2007 Posted November 27, 2007 have you tried this? int age=29; string name="Phil"; OracleCommand myComm = new OracleCommand(sql, myConn); myComm.Parameters.Add("age", OracleDbType.Int32,ParameterDirection.Input); myComm.Parameters["age"].Value = age; myComm.Parameters.Add("name", OracleDbType.Varchar2, ParameterDirection.Input); myComm.Parameters["name"].Value = name; int rowsAffected = myComm.ExecuteNonQuery(); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.