Phone number as integer bug

anaylor01

Well-Known Member
Licensed User
Longtime User
I import a csv into a table. The phone field is an integer. I than put the number into a variable which is also an integer. Now everything was working just fine. Then all of a sudden the number started coming showing up as a totally different number. A number that doesn't exist in the database. Anyone have any ideas on this? If I convert it to a string it comes out fine but then I can't do calculations on it.
 

klaus

Expert
Licensed User
Longtime User
I import a csv into a table.
What kind of table are you using ?
How do you populate it ?

Then all of a sudden the number started coming showing up as a totally different number.
Where and how is the number displayed ?
Couldn't you post your code so we could have a look at and see what you have done and how. Without the code it is impossible to give any concrete advise. This thread gives a summary on How to ask a question.

Best regards.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
B4X:
If FirstTime Then 
SQL1.Initialize(File.DirDefaultExternal, "PhoneNumber.db", True)
If SQL1.ExecQuerySingleResult("SELECT count(name) FROM sqlite_master WHERE type='table' AND name ='TpNumbers'") = 0 Then
SQL1.ExecNonQuery("CREATE TABLE TpNumbers (id int, number string, message char(200), Sent char(3))")
End If
If SQL1.ExecQuerySingleResult("SELECT count(id) FROM TpNumbers") = 0 Then
   SQL1.Initialize(File.DirDefaultExternal, "PhoneNumber.db", True)
Dim su As StringUtils
Dim Table As List
Table = su.LoadCSV(File.DirAssets, "201Myapp.csv", ",")
Dim Table2 As List
Dim Items() As String
Table2.Initialize
For i = 0 To Table.Size - 1
 Items = Table.Get(i)
 Dim m As Map
 m.Initialize
m.Put("ID", Items(0))
m.Put("number", Items(1))
m.Put("message", Items(2))
m.Put("sent",Items(3))
 Table2.Add(m)
Next
DBUtils.InsertMaps(SQL1, "TpNumbers", Table2)
   End If
End If
   SQL1.Initialize(File.DirDefaultExternal, "PhoneNumber.db", True)
number = SQL1.ExecQuerySingleResult("SELECT min(number) FROM TpNumbers where sent = 'NO'")
Activity.LoadLayout("SmsLayout") 
number = NumberFormat2(number, 0, 0, 0, False)
label1.Text = number
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Ok.. Got it figured out. Had to make the variable a long. The database datatype a numeric(10) and all is good now. That is so weird. It worked fine yesterday no problem.
 
Upvote 0
Top