using System;
using System.Data;
using System.Data.OracleClient;
class Class1
{
static void Main(string[] args)
{
string connString = "User Id=" + args[0].ToString() + ";";
connString += "Password=" + args[1].ToString() + ";";
connString += "Data Source=" + args[2].ToString();
OracleConnection oraConn = new OracleConnection();
oraConn.ConnectionString = connString;
string sqlStatement = "select * from " + args[3].ToString();
int fieldCount = 0;
int i = 0;
oraConn.Open();
if (oraConn.State == ConnectionState.Open)
{
OracleCommand cmdSQL = new OracleCommand(sqlStatement,oraConn);
OracleDataReader dataReader = cmdSQL.ExecuteReader();
fieldCount = dataReader.FieldCount;
for (i = 0; i < fieldCount; i++)
{
Console.Write(dataReader.GetName(i));
if (i < fieldCount - 1)
{
Console.Write(",");
}
}
Console.WriteLine();
while (dataReader.Read())
{
for (i = 0; i < fieldCount; i++)
{
if (!dataReader.IsDBNull(i))
{
Console.Write(dataReader[i].ToString());
}
else
{
Console.Write("(null)");
}
if (i < fieldCount - 1)
{
Console.Write(",");
}
}
}
}
if (oraConn.State == ConnectionState.Open)
{
oraConn.Close();
}
oraConn.Dispose();
}
}