Exemple #1
0
        public ProgramTester()
        {
            connstr = DatabaseSetup.GetConnectionStringsConfig("MyCon");
            SqlConnection connsql = new SqlConnection(connstr);
            StreamWriter  SW      = new StreamWriter("C:\\TEST.TXT");

            try
            {
                SW.WriteLine("测试计算的构造器" + connstr);
                SW.Flush();
                connsql.Open();
                bolconn = true;
                SW.WriteLine(bolconn);
                SW.Flush();
                SW.Close();
            }
            catch (Exception error)
            {
                SW.WriteLine(error.Message);
                SW.Flush();
                SW.Close();
                bolconn = false;
                if (connsql != null)
                {
                    connsql.Dispose();
                }
            }
            finally
            {
                connsql.Close();
            }
        }
Exemple #2
0
        public DBReturnStateTypeTest()
        {
            connstr = DatabaseSetup.GetConnectionStringsConfig("MyCon");
            SqlConnection connsql = new SqlConnection(connstr);
            //try
            //{
            //    File.Create("C:\\TESTlog.TXT");
            // string strOldText = File.ReadAllText("C:\\TESTlog.TXT", System.Text.Encoding.Default);

            //    File.AppendAllText("C:\\TESTlog.TXT", connstr, System.Text.Encoding.Default);
            //}
            //catch
            //{

            //}
            StreamWriter SW = new StreamWriter("C:\\TEST.TXT");

            try
            {
                SW.WriteLine("DBReturnStateTypeTest" + connstr);
                SW.Flush();
                connsql.Open();
                bolconn = true;
                SW.WriteLine(bolconn);
                SW.Flush();
                SW.Close();
            }
            catch (Exception error)
            {
                SW.WriteLine(error.Message);
                SW.Flush();
                SW.Close();
                bolconn = false;
                if (connsql != null)
                {
                    connsql.Dispose();
                }
            }
            finally
            {
                connsql.Close();
                if (connsql != null)
                {
                    connsql.Dispose();
                }
            }
        }