日期:2014-05-18 浏览次数:21286 次
public static int AddUsers(Users user) { int n = 0; try { string sql = "insert into users values(id_seq.nextval,'@name',@age,'@sex');"; OracleParameter name = new OracleParameter("@name",user.Name); OracleParameter age = new OracleParameter("@age", user.Age); OracleParameter sex = new OracleParameter("@sex",user.Sex); OracleCommand command = command = new OracleCommand(sql, DBHelper.connection); command.Parameters.Add(name); command.Parameters.Add(age); command.Parameters.Add(sex); DBHelper.connection.Open(); Console.WriteLine(sql); n = command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { DBHelper.connection.Close(); } return n; }
string sql = "insert into users (ID,NAME,AGE,SEX) values (id_seq.nextval,:NAME,:AGE,:SEX)";