Ejemplo n.º 1
0
        public void initMySQL()
        {
            SetupMySQLConnection(mConnInfo);

            try
            {
                mDBOperator.Open();
                mDBOperator.Close();
            }
            catch (MySqlException e)
            {
                if (e.Number == 1049)//create database
                {
                    mDBOperator.Close();

                    mDBOperator = new QuatMySQLOps(mConnInfo.Server, "",
                                                   mConnInfo.Port, mConnInfo.UserName, mConnInfo.Password);
                    mDBOperator.Open();
                    mDBOperator.ExecuteX("create database PCATDB");
                    mDBOperator.Close();

                    mDBOperator = new QuatMySQLOps(mConnInfo.Server, mConnInfo.DBName,
                                                   mConnInfo.Port, mConnInfo.UserName, mConnInfo.Password);

                    if (!mDBOperator.TableExists(Names.USER_TABLE_NAME))
                    {
                        CreateUserTable();
                    }

                    if (!mDBOperator.TableExists(Names.ODOMETER_TABLENAME))
                    {
                        CreateOdometer();
                    }
                }
                else if (e.Number == 1042)//wrong connection input
                {
                    throw e;
                }
            }
            finally
            {
                if (mDBOperator != null)
                {
                    mDBOperator.Close();
                }
            }
        }
Ejemplo n.º 2
0
 public void SetupMySQLConnection(ConnectionInfo ConnInfo)
 {
     mDBOperator = new QuatMySQLOps(ConnInfo.Server, ConnInfo.DBName,
                                    ConnInfo.Port, ConnInfo.UserName, ConnInfo.Password);
 }
Ejemplo n.º 3
0
 public void SetupSQLiteConnection(String path)
 {
     mDBOperator = new QuatSQLiteOps(path);
 }