using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient; using System.Data; using System.IO; namespace ExportDataTableApplication { class ExportDataTable { DateTime datetime = DateTime.Now; //Execute stored procedure static void Main(string[] args) { Console.WriteLine("Running App"); DataSet ds = new DataSet(); DateTime datetime = DateTime.Now; using (SqlConnection conn = new SqlConnection("Test connection string")) { string filePath = @"C:\Error.txt"; try { SqlCommand sqlComm = new SqlCommand("Test", conn); sqlComm.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(sqlComm); da.Fill(ds); } catch (Exception e) { Console.WriteLine(e.ToString()); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine("Date :" + DateTime.Now.ToString() + "=> Exception :" + e.Message + "<br/>" + Environment.NewLine + "StackTrace :" + e.StackTrace + "" + Environment.NewLine); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)