# Dictionary with values in array 

**URL:** <https://forum.xojo.com/t/dictionary-with-values-in-array/30901>\
**Category:** Getting Started\
**Created:** [April 16, 2016, 5:23am UTC](https://forum.xojo.com/t/dictionary-with-values-in-array/30901 "2016-04-16T05:23:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LAM\_YUK\_HONG](https://forum.xojo.com/user_avatar/forum.xojo.com/lam_yuk_hong/32/529_2.png) [@LAM\_YUK\_HONG](https://forum.xojo.com/u/LAM_YUK_HONG)\
**Post date:** [April 16, 2016, 5:23am UTC](https://forum.xojo.com/t/dictionary-with-values-in-array/30901/1 "2016-04-16T05:23:47Z")

</div>

The situation is, I would like to load a relatively static table in memory to use everywhere in the app. For instance:

GUID Name Score  
101 Peter 98  
202 Sam 70  
212 Shirley 100

I can use in-Memory SQLite to store, but what if I want to use a Dictionary? What is the difference between the 2?

Seems that this doesn’t work:

a(0) = rs.Name  
a(1) = rs.Score  
myDictionary.Value(rs.GUID) = a

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [April 16, 2016, 5:38am UTC](https://forum.xojo.com/t/dictionary-with-values-in-array/30901/2 "2016-04-16T05:38:07Z")

</div>

create a CLASS with properties of NAME and SCORE  
and create a DICTIONARY where “a” is a reference to an instance of the class

```auto
// assuming class "myRecord" has been defined already
myDictionary.value(guid)=new myRecord(name,score)
```

If you are just going to a simple “storage vessel” with keyed access (ie. by GUID) and the number of values is fairly small than a dictionary might be fine, if it is larger, then the power of a database and ability to use SQL to manipulate it is better.

Also if you want to do statistical functions such as find max score, averages, etc… a database and sql would be easier.

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [April 16, 2016, 7:51am UTC](https://forum.xojo.com/t/dictionary-with-values-in-array/30901/3 "2016-04-16T07:51:33Z")

</div>

[quote=259960:@Tony Lam]a(0) = rs.Name  
a(1) = rs.Score  
myDictionary.Value(rs.GUID) = a[/quote]  
Of course this will work, if done correctly. There is no rs.Name  should rs be a RecordSet , you need to use rs.Field(“Name”)…

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [April 16, 2016, 2:43pm UTC](https://forum.xojo.com/t/dictionary-with-values-in-array/30901/4 "2016-04-16T14:43:47Z")

</div>

> [@259960:@Tony Lam](#):
>
> I can use in-Memory SQLite to store, but what if I want to use a Dictionary? What is the difference between the 2?

searchablity  
searching a dictionary for complex criteria means YOU write ALL the code - to set up the criteria & to do the search  
an in memory db you just write the criteria (sql)

tested code  
sqlite is very well used & well tested  
your code less so

speed  
sqlite in memory is VERY fast  
searching a dictionary will likely be slower

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:16pm UTC](https://forum.xojo.com/t/dictionary-with-values-in-array/30901/5 "2020-10-29T18:16:20Z")

</div>


