日期:2014-05-18  浏览次数:20742 次

请问,我调用一个存储过程,向数据库中添加一条记录,怎么程序运行成功,可是数据添加不到数据库中,请各位朋友帮帮忙,看是怎么回事?谢谢!!
我的代码如下:可就是数据添加不到数据库中,不知为什么?请教帮忙?万分感谢!
OracleDataAdapter objAdapter = new OracleDataAdapter();
  OracleCommand objSelectCmd = new OracleCommand();
  objSelectCmd.Connection = PublicConn.myConn;
  if (objSelectCmd.Connection.State.ToString() == "Closed") objSelectCmd.Connection.Open();
  objSelectCmd.CommandText = "deptpackage.select_dept";
  objSelectCmd.CommandType = CommandType.StoredProcedure;
  objSelectCmd.Parameters.Add("cur_dept", OracleType.Cursor).Direction = ParameterDirection.Output;
  objAdapter.SelectCommand = objSelectCmd;

  OracleCommand objInsertCmd = new OracleCommand();
  objInsertCmd.Connection = PublicConn.myConn;
  if (objInsertCmd.Connection.State.ToString() == "Closed") objInsertCmd.Connection.Open();
  objInsertCmd.CommandText = "deptpackage.insert_dept";
  objInsertCmd.CommandType = CommandType.StoredProcedure;
  objInsertCmd.Parameters.Add("p_code", OracleType.VarChar, 20, TBcode.Text.Trim());
  objInsertCmd.Parameters.Add("p_name", OracleType.VarChar, 50, TBname.Text.Trim());
  objInsertCmd.Parameters.Add("p_ucode", OracleType.VarChar, 50, DDLunitname.Text.Trim());
  objAdapter.InsertCommand = objInsertCmd;
  DataSet ds = new DataSet();
  objAdapter.Fill(ds);
  GridView1.DataSource = ds;
  objAdapter.Update(ds);

------解决方案--------------------
try
objInsertCmd.Parameters.Add("p_code", OracleType.VarChar, 20).Value = TBcode.Text.Trim(); 
objInsertCmd.Parameters.Add("p_name", OracleType.VarChar, 50).Value = TBname.Text.Trim(); 
objInsertCmd.Parameters.Add("p_ucode", OracleType.VarChar, 50).Value = DDLunitname.Text.Trim();