本文整理汇总了C#中OracleDataReader.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# OracleDataReader.GetName方法的具体用法?C# OracleDataReader.GetName怎么用?C# OracleDataReader.GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OracleDataReader
的用法示例。
在下文中一共展示了OracleDataReader.GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessNews
public String ProcessNews()
{
using (Logger l = new Logger("PipeCatcher"))
{
OraCmd.CommandText = ProcName;
OraCmd.CommandType = System.Data.CommandType.StoredProcedure;
OraCmd.Parameters.Clear();
//OraCmd.Parameters.Add(new OracleParameter("NRECID", OracleDbType.Decimal, System.Data.ParameterDirection.Input)).Value = RecId;
OraCmd.Parameters.Add(new OracleParameter("REFCURSOR", OracleDbType.RefCursor, System.Data.ParameterDirection.Output));
if (OraCmd.Connection.State != System.Data.ConnectionState.Closed)
{
OraCmd.Connection.Close();
}
OraCmd.Connection.Open();
OraReader = OraCmd.ExecuteReader();
var str = String.Format("\nCALL {0}", ProcName);
// var mainevt = new FlexEvent("PipeCatcher.Call." + ProcName);
// mainevt.Arguments.Add("@ProcName", ProcName);
if (OraReader.HasRows)
{
var iRow = 0;
FlexEvent evt = new FlexEvent("PipeCatcher.Call." + ProcName + ".Row." + (++iRow));
str += "+++";
while (OraReader.Read())
{
for (int i = 0; i < OraReader.FieldCount; i++)
{
evt.Arguments.Add(OraReader.GetName(i), OraReader[i]);
str += "\n" + OraReader.GetName(i) + "\t: " + OraReader[i];
}
str += "\n********************";
// mainevt.Arguments.Add(String.Format("Row{0}", ++iRow), evt);
Program.CoreGate.PushEvent(evt);
evt.Arguments.Clear();
}
// Program.CoreGate.PushEvent(mainevt);
}
else
{
str += "---";
}
OraReader.Close();
l.msg(str);
return str;
}
}
示例2: ShowResultSet
void ShowResultSet(OracleDataReader reader, OracleCommand command)
{
//it is included dbms_output
command.CommandText = "begin dbms_output.enable (32000); end;";
command.CommandType = CommandType.Text;
command.ExecuteNonQuery();
bool headerPrinted = false;
int count = 1;
while (reader.Read())
{
if (!headerPrinted)
{
Console.WriteLine(@"<table class=""sqloutput""><tbody><tr><th> </th>");
for (int i = 0; i < reader.FieldCount; i++)
{
string name = reader.GetName(i);
Console.WriteLine(@"<th>{0}</th>", string.IsNullOrEmpty(name) ? "(No column name)" : name);
}
Console.WriteLine("</tr>");
headerPrinted = true;
}
Console.WriteLine(@"<tr><td>{0}</td>", count++);
for (int i = 0; i < reader.FieldCount; i++)
{
if (reader[i] == DBNull.Value)
{
Console.WriteLine(@"<td><i>NULL</i></td>");
}
else
{
if (reader[i] as string == null && reader[i] as IEnumerable != null)
{
string res = "";
foreach (var a in (reader[i] as IEnumerable))
res += Convert.ToString(a);
Console.WriteLine(@"<td>{0}</td>", res);
}
else
{
Console.WriteLine(@"<td>{0}</td>", HttpUtility.HtmlEncode(reader[i]));
}
}
}
Console.WriteLine("</tr>");
}
if (headerPrinted)
Console.WriteLine("</tbody></table>");
// create parameter objects for the anonymous pl/sql block
int NUM_TO_FETCH = 8;
OracleParameter p_lines = new OracleParameter("", OracleDbType.Varchar2, NUM_TO_FETCH, "", ParameterDirection.Output);
p_lines.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p_lines.ArrayBindSize = new int[NUM_TO_FETCH];
// set the bind size value for each element
for (int i = 0; i < NUM_TO_FETCH; i++)
{
p_lines.ArrayBindSize[i] = 32000;
}
// this is an input output parameter...
// on input it holds the number of lines requested to be fetched from the buffer
// on output it holds the number of lines actually fetched from the buffer
OracleParameter p_numlines = new OracleParameter("", OracleDbType.Decimal, "", ParameterDirection.InputOutput);
// set the number of lines to fetch
p_numlines.Value = NUM_TO_FETCH;
// set up command object and execute anonymous pl/sql block
command.CommandText = "begin dbms_output.get_lines(:1, :2); end;";
command.CommandType = CommandType.Text;
command.Parameters.Add(p_lines);
command.Parameters.Add(p_numlines);
command.ExecuteNonQuery();
// get the number of lines that were fetched (0 = no more lines in buffer)
int numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();
// as long as lines were fetched from the buffer...
while (numLinesFetched > 0)
{
// write the text returned for each element in the pl/sql
// associative array to the console window
for (int i = 0; i < numLinesFetched; i++)
{
string out_string = (string)(p_lines.Value as OracleString[])[i];
if (!string.IsNullOrEmpty(out_string))
{
Console.WriteLine(System.Web.HttpUtility.HtmlEncode(out_string));
}
}
// re-execute the command to fetch more lines (if any remain)
command.ExecuteNonQuery();
// get the number of lines that were fetched (0 = no more lines in buffer)
numLinesFetched = ((OracleDecimal)p_numlines.Value).ToInt32();
}
// clean up
p_numlines.Dispose();
p_lines.Dispose();
}
示例3: ProcessNews
public String ProcessNews()
{
using (Logger l = new Logger("PipeCatcher"))
{
OraCmd.CommandText = ProcName;
OraCmd.CommandType = System.Data.CommandType.StoredProcedure;
OraCmd.Parameters.Clear();
OraCmd.Parameters.Add(new OracleParameter("NRECID", OracleDbType.Decimal, System.Data.ParameterDirection.Input)).Value = RecId;
OraCmd.Parameters.Add(new OracleParameter("REFCURSOR", OracleDbType.RefCursor, System.Data.ParameterDirection.Output));
// OraCmd.Parameters["NRECID"].Value = RecId;
if (OraCmd.Connection.State != System.Data.ConnectionState.Closed)
{
OraCmd.Connection.Close();
}
OraCmd.Connection.Open();
OraReader = OraCmd.ExecuteReader();
var str = String.Format("\nCALL {0}({1})", ProcName, RecId);
if (OraReader.HasRows)
{
var f = new FlexHelper("PipeCatcher.Call." + ProcName);
str += "+++";
OraReader.Read();
f.AddArg("@ProcName", ProcName);
for (int i = 0; i < OraReader.FieldCount; i++)
{
f.AddArg(OraReader.GetName(i), OraReader[i]);
str += "\n" + OraReader.GetName(i) + "\t: " + OraReader[i];
}
f.Fire(Program.CoreGate);
}
else
{
str += "---";
}
OraReader.Close();
return str;
}
}
示例4: Serialize
public IEnumerable<Dictionary<string, object>> Serialize(OracleDataReader reader)
{
var results = new List<Dictionary<string, object>>();
var cols = new List<string>();
for (var i = 0; i < reader.FieldCount; i++)
{
if (!cols.Contains(reader.GetName(i)))
{
cols.Add(reader.GetName(i));
}
}
while (reader.Read())
{
results.Add(SerializeRow(cols, reader));
}
return results;
}