日期:2014-05-17 浏览次数:20545 次
private string DoInsert(HttpContext context) { string result = ""; string name=context.Request.Params["name"]; string parentid = context.Request.Params["parentid"]; if (name != null && parentid != null) { OracleConnection conn = new OracleConnection("Data Source=wgyx;user=wgyx;password=wgyx;"); OracleCommand cmd = new OracleCommand("INSERT INTO newclass ( cName, parentid ) VALUES(name,parentid)", conn); cmd.Parameters.AddWithValue("name", name); cmd.Parameters.AddWithValue("parentid", int.Parse(parentid)); try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); cmd.CommandText = "Select max(id) from newclass"; cmd.Parameters.Clear(); conn.Open(); result = cmd.ExecuteScalar().ToString(); conn.Close(); } catch (Exception ex) { result = "-1"; } finally { conn.Close(); } } else { result = "-1"; } return result; }