KeyValueStore, string with leading zero is stripped.

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi All

Using the KeyValueStore cls and when storing a string value with putsimple, would appear that the value when it is "+353..." or "087...." both the + and the 0 are not stored.

This is kind of important as the string is a phone number and need the preceding + or 0.

Regards

John .:confused:
 

agraham

Expert
Licensed User
Longtime User
Looks like SQLite is treating those Strings as numbers when it stores and retrieves them. Using PutObject and GetObject seem to work OK but are inefficient. It might be better to keep using PutSimple and GetSimple and prefix the values with a non-numeric character and remove it when reading so SQLite treats the values as Strings.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi Andrew

Yep, I have had to use that technique before, I was hoping that their was a cleaner solution to it.

Cheers.

John.
 
Upvote 0

AllyAndroid

Member
Licensed User
Longtime User
Upvote 0

juanjo.miracle

New Member
Licensed User
Longtime User
Another workaround, if you planned to use KeyValueStore only to work with strings you can change de CreateTable Sub by replacing "value NONE" with "value TEXT".
I suggest make your own KeyValueStore Class removing the methods that you don't use.

Private Sub CreateTable
sql1.ExecNonQuery("CREATE TABLE IF NOT EXISTS main(key TEXT PRIMARY KEY, value TEXT)")
End Sub
 
Upvote 0
Top