Пример #1
0
 static void Main()
 {
     try
     {
         bool New;
         Mutex instance = new Mutex(true, "大屏显示程序", out New);
         if (New)
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             Application.Run(new LedFrm());
         }
         else
         {
             MessageBox.Show("已经启动了一个程序,请先退出!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Application.Exit();
         }
     }
     catch (Exception ee)
     {
         ErrorWriter ew = new ErrorWriter();
         ew.MonthErrorWriter(ee.StackTrace.ToString() + "||" + ee.Message.ToString());
     }
 }
Пример #2
0
        /// <summary>
        /// 通用查询
        /// </summary>
        /// <param name="sql">string sql</param>
        /// <returns>DataTable</returns>
        public static DataTable GetDataTable(string sql)
        {
            try
            {
                if (connection == "")
                {
                    sqlconnection();
                }
                using (SqlConnection con = new SqlConnection(connection))
                {
                    SqlDataAdapter sda = new SqlDataAdapter(sql, con);
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    return dt;
                }
            }
            catch (Exception ee)
            {
                ErrorWriter ew = new ErrorWriter();
                ew.MonthErrorWriter(ee.StackTrace + "||" + ee.Message);
                return null;
            }

        }