コード例 #1
0
ファイル: ImportAccess.cs プロジェクト: c1982/mpimport
        private List<DatabaseUser> GetDatabaseUsers(int databaseId)
        {
            var _tmp = new List<DatabaseUser>();

            using (OleDbConnection _conn = new OleDbConnection(Settings.Default.connectionString))
            {
                _conn.Open();
                using (OleDbCommand _cmd = new OleDbCommand(@"SELECT login, passwd FROM db_users WHERE (db_id = ?) AND (status = 'normal')", _conn))
                {
                    _cmd.CommandType = CommandType.Text;
                    _cmd.Parameters.AddWithValue("ID", databaseId);

                    using (OleDbDataReader _read = _cmd.ExecuteReader())
                    {
                        while (_read.Read())
                        {
                            var _d = new DatabaseUser();
                            _d.Username = _read["login"].ToString();
                            _d.Password = _read["passwd"].ToString();

                            _tmp.Add(_d);
                        }
                    }
                }
                _conn.Close();
            }

            return _tmp;
        }
コード例 #2
0
ファイル: MpImportSQLite.cs プロジェクト: c1982/mpimport
        private List<DatabaseUser> GetMySqlDatabaseUsers(int databaseId)
        {
            var _tmp = new List<DatabaseUser>();

            using (SQLiteConnection _conn = new SQLiteConnection(Settings.Default.connectionString))
            {
                _conn.Open();
                using (SQLiteCommand _cmd = new SQLiteCommand(@"SELECT Username, Password FROM DomainMySQLUser WHERE DatabaseId = $ID", _conn))
                {
                    _cmd.Parameters.AddWithValue("$ID", databaseId);

                    using (SQLiteDataReader _read = _cmd.ExecuteReader())
                    {
                        while (_read.Read())
                        {
                            var _d = new DatabaseUser();
                            _d.Username = _read["Username"].ToString();
                            _d.Password = _read["Password"].ToString();

                            _tmp.Add(_d);
                        }
                    }
                }
                _conn.Close();
            }

            return _tmp;
        }