public String ExecProcValue(String procedureName, Dictionary <String, object> procedureParameters, DbConnection connection = null) { var result = ""; ConnectionPoolNode node = null; try { if (connection == null) { node = connection_pool.GetNode(); connection = node.connection; } var cmd = MakeCommand(connection, procedureName, procedureParameters); DbParameter p_ = cmd.CreateParameter(); p_.ParameterName = "@value"; p_.Value = -1; p_.Direction = ParameterDirection.Output; cmd.Parameters.Add(p_); try { cmd.Prepare(); DataTable dt = new DataTable(); using (IDataReader dr = cmd.ExecuteReader()) { if (dr.FieldCount > 0) { for (int i = 0; i < dr.FieldCount; i++) { DataColumn dc = new DataColumn(dr.GetName(i), dr.GetFieldType(i)); dt.Columns.Add(dc); } object[] rowobject = new object[dr.FieldCount]; while (dr.Read()) { dr.GetValues(rowobject); dt.LoadDataRow(rowobject, true); } } } result = cmd.Parameters["@value"].Value.ToString(); } finally { cmd.Dispose(); } } finally { if (node != null) { node.Free(); } } return(result); }
public DataTable ExecProc(String procedureName, Dictionary <String, object> procedureParameters, DbConnection connection = null, Boolean silent = false) { ConnectionPoolNode node = null; DataTable dt = null; try { if (connection == null) { node = connection_pool.GetNode(); connection = node.connection; } var cmd = MakeCommand(connection, procedureName, procedureParameters); try { cmd.Prepare(); dt = new DataTable(); using (IDataReader dr = cmd.ExecuteReader()) { if (dr.FieldCount > 0) { for (int i = 0; i < dr.FieldCount; i++) { DataColumn dc = new DataColumn(dr.GetName(i), dr.GetFieldType(i)); dt.Columns.Add(dc); } object[] rowobject = new object[dr.FieldCount]; while (dr.Read()) { dr.GetValues(rowobject); dt.LoadDataRow(rowobject, true); } } } } finally { cmd.Dispose(); } } finally { node.Free(); } return(dt); }