S swabygw Active Member Licensed User Longtime User Jan 2, 2017 #1 I have a custom Type, like this: Code: Copy Type MyCustomType (UserID As Int, Active As Boolean, EffDt As Long) I read from a database (msaccess) and load the retrieved values into the custom Type, like this: Code: Copy Dim m As Map m = rows.Get(i) Log(m) Select Job.JobName Case "MyJobName" Dim pr As MyCustomType pr.UserID = m.Get("UserID") pr.Active = m.Get("Active") pr.EffDt = m.Get("EffDt") ListOfMyCustomType.Add(pr) End Select My goal is simply to load the ticks into pr.Effdt. I can see from the Log that it has retrieved ticks, which is perfect, but marked the value as a /Date/ - see image. This is okay with me, but it causes an error on the line pr.Effdt=m.Get("EffDt"). Strangely, the error says "Invalid double" even though the datatype of the target field is Long. This should work, no? Is there another (better) way to load a date? P.S., my temporary workaround is: Code: Copy Dim s As String = m.Get("EffDt") s = s.SubString2(6, s.Length-2) pr.EffDt = s Last edited: Jan 2, 2017
I have a custom Type, like this: Code: Copy Type MyCustomType (UserID As Int, Active As Boolean, EffDt As Long) I read from a database (msaccess) and load the retrieved values into the custom Type, like this: Code: Copy Dim m As Map m = rows.Get(i) Log(m) Select Job.JobName Case "MyJobName" Dim pr As MyCustomType pr.UserID = m.Get("UserID") pr.Active = m.Get("Active") pr.EffDt = m.Get("EffDt") ListOfMyCustomType.Add(pr) End Select My goal is simply to load the ticks into pr.Effdt. I can see from the Log that it has retrieved ticks, which is perfect, but marked the value as a /Date/ - see image. This is okay with me, but it causes an error on the line pr.Effdt=m.Get("EffDt"). Strangely, the error says "Invalid double" even though the datatype of the target field is Long. This should work, no? Is there another (better) way to load a date? P.S., my temporary workaround is: Code: Copy Dim s As String = m.Get("EffDt") s = s.SubString2(6, s.Length-2) pr.EffDt = s
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2017 #2 Why are you using ms access? Use KeyValueStore2 and store the custom type directly in the database. https://www.b4x.com/android/forum/posts/404447/ Upvote 0
Why are you using ms access? Use KeyValueStore2 and store the custom type directly in the database. https://www.b4x.com/android/forum/posts/404447/
S swabygw Active Member Licensed User Longtime User Jan 2, 2017 #3 Interesting - didn't know KeyValueStore2 was that powerful. But, I need to access the data from my web server as the data is viewed/manipulated from a website, too. I thought a database sitting on the web server made the most sense, but now I'm wondering if it would be wiser to use KeyValueStore2 and sync it to my database somehow. Upvote 0
Interesting - didn't know KeyValueStore2 was that powerful. But, I need to access the data from my web server as the data is viewed/manipulated from a website, too. I thought a database sitting on the web server made the most sense, but now I'm wondering if it would be wiser to use KeyValueStore2 and sync it to my database somehow.
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2017 #4 MS Access is for sure the wrong solution. Anyway you can parse the string and extract the number. Code: Copy Dim s As String = m.Get("EffDt") Dim i1 As Int = s.IndexOf("(") Dim i2 As Int = s.IndexOf(")") Dim ticks As Long = s.SubString2(i1 + 1, i2) Upvote 0
MS Access is for sure the wrong solution. Anyway you can parse the string and extract the number. Code: Copy Dim s As String = m.Get("EffDt") Dim i1 As Int = s.IndexOf("(") Dim i2 As Int = s.IndexOf(")") Dim ticks As Long = s.SubString2(i1 + 1, i2)
S swabygw Active Member Licensed User Longtime User Jan 2, 2017 #5 Thanks - hopefully, MSAccess is only temporary (SQLServer is the long-term goal). Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jan 2, 2017 #6 You should use jRDC2 to connect to a remote server. It will properly serialize the types for you. Upvote 0
S swabygw Active Member Licensed User Longtime User Jan 2, 2017 #7 Cool - I'll try it for the next upscale away from MSAccess. Upvote 0