try { openConnection(); comm.CommandType =CommandType.Text ; comm.CommandText =sqlstr; comm.ExecuteNonQuery(); } catch(Exception e) { throw new Exception(e.Message); } finally { closeConnection(); } } /// <summary> /// 执行存储过程 /// </summary> /// <param name="procName">存储过程名</param> /// <param name="coll">SqlParameters 集合</param> public static void ExecutePorcedure(string procName,SqlParameter[] coll) { try { openConnection(); for(int i=0;i<coll.Length;i++) { comm.Parameters .Add(coll[i]); } comm.CommandType=CommandType.StoredProcedure ; comm.CommandText =procName; comm.ExecuteNonQuery(); } catch(Exception e) { throw new Exception(e.Message); } finally { comm.Parameters.Clear(); closeConnection(); } } /// <summary> /// 执行存储过程并返回数据集 /// </summary> /// <param name="procName">存储过程名称</param> /// <param name="coll">SqlParameter集合</param> /// <param name="ds">DataSet </param> public static void ExecutePorcedure(string procName,SqlParameter[] coll,ref DataSet ds) { try { SqlDataAdapter da=new SqlDataAdapter(); openConnection(); for(int i=0;i<coll.Length;i++) { comm.Parameters .Add(coll[i]); |