本文介绍了我能成功创建日志吗?我暂时不能尝试,建议谢谢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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);
                    }
                }

推荐答案



这篇关于我能成功创建日志吗?我暂时不能尝试,建议谢谢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:21