Ejemplo n.º 1
0
        public static void kDemoRun(string server = cServer, string userName = cUserName, string passWord = cPassword, string dbName = cDatabase, string port = cPort)
        {
            try
            {
                string connStr = string.Format(cConnectionStringFormat, server, userName, passWord, dbName, port);


                IList <AkmTest> list = new List <AkmTest>();

                using (var connec = new MySqlConnection(connStr))
                {
                    using (var comman = new MySqlCommand())
                    {
                        connec.Open();
                        comman.Connection     = connec;
                        comman.CommandText    = "select timestamp, msg from axts_test";
                        comman.CommandTimeout = 0;
                        MySqlDataReader reader = comman.ExecuteReader();

                        while ((reader.Read()))
                        {
                            AkmTest ob = new AkmTest();

                            ob.Timestamp = Convert.ToDateTime(reader["timestamp"]);
                            ob.Msg       = Convert.ToString(reader["msg"]);
                            list.Add(ob);
                        }
                        connec.Close();
                    }
                }

                foreach (var c in list)
                {
                    Console.WriteLine(c.Timestamp + " - " + c.Msg);
                }

                Console.WriteLine("Success");
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }
        }
Ejemplo n.º 2
0
        public static void kDemoRun(string server = cServer, string userName = cUserName, string passWord = cPassword, string dbName = cDatabase,  string port = cPort)
        {
            try
            {
                string connStr = string.Format(cConnectionStringFormat, server, userName, passWord, dbName, port);

                IList<AkmTest> list = new List<AkmTest>();

                using (var connec = new MySqlConnection(connStr))
                {
                    using (var comman = new MySqlCommand())
                    {
                        connec.Open();
                        comman.Connection = connec;
                        comman.CommandText = "select timestamp, msg from axts_test";
                        comman.CommandTimeout = 0;
                        MySqlDataReader reader = comman.ExecuteReader();

                        while ((reader.Read()))
                        {
                            AkmTest ob = new AkmTest();

                            ob.Timestamp = Convert.ToDateTime(reader["timestamp"]);
                            ob.Msg = Convert.ToString(reader["msg"]);
                            list.Add(ob);
                        }
                        connec.Close();
                    }
                }

                foreach (var c in list)
                {
                    Console.WriteLine(c.Timestamp + " - " + c.Msg);
                }

                Console.WriteLine("Success");
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }
        }