日期:2014-05-18 浏览次数:20897 次
public static string[] GetTopRecord(OracleConnection conn, OracleTransaction trans, CommandType cmdType, string cmdText, params OracleParameter[] cmdParms) { OracleCommand cmd = null; OracleDataReader reader = null; try { string[] strArray = null; cmd = new OracleCommand(); //绑定cmd参数,链接,并且打开数据库链接 PrepareCommand(cmd, conn, trans, cmdType, cmdText, cmdParms); reader = cmd.ExecuteReader(); if (reader.Read()) { strArray = new string[reader.FieldCount]; for (int i = 0; i < reader.FieldCount; i++) { strArray[i] = reader.IsDBNull(i) ? string.Empty : reader.GetValue(i).ToString(); } } return strArray; } finally { if (!reader.IsClosed) { reader.Close(); reader.Dispose(); reader = null; } cmd.Dispose(); if (conn != null && conn.State != ConnectionState.Closed) { conn.Close(); conn.Dispose(); conn = null; } } }