private static SqlCeDatabase GetDatabase()
        {
            SqlCeDatabase db = null;

            if (!string.IsNullOrEmpty(m_Settings.ConnectionString))
            {
                db = new SqlCeDatabase(m_Settings.ConnectionString);
            }
            else
            {
                //db = DatabaseFactory.CreateDatabase();
            }

            return db;
        }
        internal static object ExecuteScalarFromSql(SqlCeDatabase database, string query, FieldValue[] fieldValueArray)
        {
            SqlCeCommand dbCommand;
            Object obj = null;

            dbCommand = database.GetSqlStringCommand(query);

            if (dbCommand != null)
            {
                try
                {

                    SetCommandProperties(dbCommand);

                    if (fieldValueArray != null && fieldValueArray.Length > 0)
                    {
                        dbCommand.Parameters.AddRange(GetParameters(fieldValueArray));
                    }

                    obj = database.ExecuteScalar(dbCommand);
                    if (obj is DBNull)
                    {
                        obj = null;
                    }

                }
                finally
                {
                    dbCommand.Dispose();
                }
            }

            return obj;
        }
        internal static int ExecuteNonQueryFromSql(SqlCeDatabase database, string query, FieldValue[] fieldValueArray)
        {
            SqlCeCommand dbCommand;
            int rtnValue = -1;

            dbCommand = database.GetSqlStringCommand(query);

            if (dbCommand != null)
            {
                try
                {

                    SetCommandProperties(dbCommand);

                    if (fieldValueArray != null && fieldValueArray.Length > 0)
                    {
                        dbCommand.Parameters.AddRange(GetParameters(fieldValueArray));
                    }

                    rtnValue = database.ExecuteNonQuery(dbCommand, false);

                }
                finally
                {
                    dbCommand.Dispose();
                }
            }

            return rtnValue;
        }
        internal static IDataReader ExecuteReaderFromSql(SqlCeDatabase database, string query, FieldValue[] fieldValueArray)
        {
            SqlCeCommand dbCommand;
            IDataReader rdr = null;

            dbCommand = database.GetSqlStringCommand(query);

            if (dbCommand != null)
            {
                try
                {

                    SetCommandProperties(dbCommand);

                    if (fieldValueArray != null && fieldValueArray.Length > 0)
                    {
                        dbCommand.Parameters.AddRange(GetParameters(fieldValueArray));
                    }

                    rdr = database.ExecuteReader(dbCommand);

                }
                finally
                {
                    dbCommand.Dispose();
                }
            }

            return rdr;
        }
        internal static SqlCeResultSet ExecuteDataSetFromSql(SqlCeDatabase database, string query, FieldValue[] fieldValueArray)
        {
            SqlCeCommand dbCommand;
            SqlCeResultSet dataSet = null;

            dbCommand = database.GetSqlStringCommand(query);

            if (dbCommand != null)
            {
                try
                {

                    SetCommandProperties(dbCommand);

                    if (fieldValueArray != null && fieldValueArray.Length > 0)
                    {
                        dbCommand.Parameters.AddRange(GetParameters(fieldValueArray));
                    }

                    dataSet = database.ExecuteDataSet(dbCommand);

                }
                finally
                {
                    dbCommand.Dispose();
                }
            }

            return dataSet;
        }