示例#1
0
        public void GetName()
        {
            int rowNum = Random(Count);
            command = "select " + Table + ", russian from " + Table + " where id = " + rowNum.ToString();

            MySQLConn connection = new MySQLConn();
            connection.OpenConnection();
            try
            {
                MySqlCommand sqlCom = new MySqlCommand(command, MySQLConn.conn);

                using (var reader = sqlCom.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        Eng = reader[0].ToString();
                        Rus = reader[1].ToString();
                    }
                    else
                    {
                        Eng = "Achtung!";
                        Rus = "Achtung!";
                    }
                }
            }
            finally
            {
                connection.CloseConnection();
            }

            if (Eng == "Achtung!" || Rus == "Achtung!")
                GetName();
        }
示例#2
0
 private int GetCountOf(string table)
 {
     long ret = 0;
     MySQLConn connection = new MySQLConn();
     connection.OpenConnection();
     try
     {
         string command = "select count(*) from " + table;
         MySqlCommand sqlCom = new MySqlCommand(command, MySQLConn.conn);
         ret = (long)sqlCom.ExecuteScalar();
     }
     finally
     {
         connection.CloseConnection();
     }
     return int.Parse(ret.ToString());
 }
示例#3
0
        public static void LogName(GeneratedName name)
        {
            MySQLConn connection = new MySQLConn();

            connection.OpenConnection();
            try
            {
                string command = "insert into log (`eng_name`, `rus_name`, `date_of_birth`,	`comment`) values ('" + name.EngName + "', '" + name.RusName
                                 + "', '" + name.DateOfBirth + "', '" + name.Comment + "')";
                MySqlCommand sqlCom = new MySqlCommand(command, MySQLConn.conn);
                sqlCom.ExecuteNonQuery();
            }
            finally
            {
                connection.CloseConnection();
            }
        }
示例#4
0
        private void RefreshNameTable()
        {
            DisplayResults.Visible = true;
            MySQLConn connection = new MySQLConn();

            connection.OpenConnection();
            try
            {
                string       command = "SELECT * FROM log order by id desc limit 1000";
                MySqlCommand sqlCom  = new MySqlCommand(command, MySQLConn.conn);

                MySqlDataReader reader = sqlCom.ExecuteReader();
                grid.DataSource = reader;
                grid.DataBind();
                reader.Close();
            }
            finally
            {
                connection.CloseConnection();
            }
        }