web site statistics

punyadimas.com

.:: semua punyadimas ! ::.

using System;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;
using System.IO;
//using Oracle.DataAccess.Client;
//using Oracle.DataAccess.Types;
namespace AutoReport
{
class Program
{
static void Main(string[] args)
{
DateTime time = DateTime.Now.AddDays(-1);
string format = “dMMyyyy”;
string format1 = “d-MMMM-yyyy”;
string ConnString = ConfigurationManager.AppSettings["nama1"];
StreamReader re = File.OpenText(“jamu.dim”);
string input = re.ReadLine();
string a = input;
OracleConnection con = new OracleConnection();
con.ConnectionString = input;
try
{
con.Open();
//con.Open();
//Console.WriteLine(“masuk”);
string Query = “select * from sub_branch”;
OracleCommand OC = new OracleCommand(Query, con);
OC.CommandType = CommandType.Text;
OracleDataReader ODR = OC.ExecuteReader();
while (ODR.Read())
{
string path = @”c:\report\” + ODR.GetValue(1) + “-” + time.ToString(format) + “.txt”;
string cmdQuery = “SELECT SUB_CODE, NO_PO, DT, MENU_CODE, QTY, DISKON FROM REPORT_SAP WHERE SUB_CODE =” + ODR.GetValue(1) + ” and dated = ” + “‘” + time.ToString(format1) + “‘”;
//string cmdQuery = “SELECT * FROM REPORT_SAP WHERE SUB_CODE =” + i;
OracleCommand cmd = new OracleCommand(cmdQuery);
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
try
{
if (File.Exists(path))
{
File.Delete(path);
}
using (StreamWriter sw = new StreamWriter(path))
{
OracleDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
sw.WriteLine(reader.GetValue(0) + “\t” + reader.GetValue(1) + “\t” + reader.GetValue(2) + “\t” + reader.GetValue(3) + “\t” + reader.GetValue(4) + “\t” + reader.GetValue(5));
}
}
using (StreamReader sr = new StreamReader(path))
{
while (sr.Peek() >= 0)
{
Console.WriteLine(sr.ReadLine());
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine(“Exporting…..”);
}
}
catch (Exception ex)
{
Console.WriteLine(“Conntion To Databases Erorr at = ” + ex.Message);
}
finally
{
con.Close();
con.Dispose();
}
}
}
}

No Comments :(