Ejemplo n.º 1
0
        private int ExecuteSQL(string SQLD)
        {
            string m_GetID    = "SELECT LAST_INSERT_ID()";  // Grab the ID of last instered row
            int    m_ObjectID = 0;

            // Connect to Database and update
            MySqlConnection m_Connection   = new MySqlConnection(SQLData.ConnStr(m_DataBase));
            MySqlCommand    m_CommandAdd   = new MySqlCommand(SQLD, m_Connection);
            MySqlCommand    m_CommandGetID = new MySqlCommand(m_GetID, m_Connection);

            try
            {
                // Execute Command
                m_Connection.Open();
                m_CommandAdd.ExecuteNonQuery();
                MySqlDataReader m_Reader = m_CommandGetID.ExecuteReader();  // Get ID
                m_Reader.Read();                                            // Read in data
                m_ObjectID = m_Reader.GetInt32(0);
                m_Connection.Close();
            }
            catch (Exception Error)
            {
                MessageBox.Show("SQL Error: " + Error.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(-1);
            }

            return(m_ObjectID);
        }
Ejemplo n.º 2
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            MySqlConnection mySqlConnection = null;

            try
            {
                SQLData.User    = LoginUsername.Text;
                SQLData.Pass    = LoginPassword.Text;
                SQLData.Host    = SQLServer.Text;
                SQLData.Port    = System.Convert.ToInt32(SQLPort.Text, 10);
                mySqlConnection = new MySqlConnection(SQLData.ConnStr("net7"));
                MySqlCommand m_Command = new MySqlCommand("SELECT `versions`.`Version` FROM `versions` WHERE `versions`.`EName` = 'Station'", mySqlConnection);

                mySqlConnection.Open();

                MySqlDataReader ReadData = m_Command.ExecuteReader();

                if (ReadData.HasRows)
                {
                    ReadData.Read();
                    if (ReadData.GetString(0) != System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString())
                    {
                        MessageBox.Show("You are running an old version.  Please update your editor.", "Old Version", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        m_Cancel = true;
                    }
                    else
                    {
                        m_Cancel = false;
                        m_Login  = true;
                    }
                }
                else
                {
                    m_Cancel = true;
                }
                this.Close();
            }
            catch (Exception connectionException)
            {
                System.Windows.Forms.MessageBox.Show(connectionException.Message, "Connection Error");
            }
            finally
            {
                if (mySqlConnection != null)
                {
                    mySqlConnection.Close();
                }
            }
        }
Ejemplo n.º 3
0
        private MySqlDataReader ExcuteSQLQuery(string SQLD)
        {
            // Populate the Starbase Combox
            MySqlConnection m_Connection = new MySqlConnection(SQLData.ConnStr(m_DataBase));
            MySqlCommand    m_Command    = new MySqlCommand(SQLD, m_Connection);

            try
            {
                m_Connection.Open();
            }
            catch (Exception Error)
            {
                MessageBox.Show("SQL Error: " + Error.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(m_Command.ExecuteReader());
        }