Android Question SQLite Strange Behaviour

Terradrones

Active Member
Hi All

I need a hint again please.

When I import Design Files (like a Horizontal Alignment) from either a CSV or Text file, everything is fine. I have a MSGBox, that shows me the imported Data for every line.

This the code that I am using:

Import Data:
[
Sub ImportTextFiles
    Dim SU As StringUtils
    Dim Table As List
    Dim fd As FileDialog
   
    fd.FilePath = File.DirRootExternal
    fd.TextColor=Colors.Black
    fd.ScrollingBackgroundColor=Colors.Gray
   
    If Button1.Checked=True Then
        'Import CSV
        fd.FileFilter=".csv"
    Else IF Button2.Checked=True Then
        'Import Text
        fd.FileFilter=".txt"
    End If
   
    Dim sf As Object = fd.ShowAsync("Select File To Import", "Import", "Cancel", "", Null, False)
    Wait For (sf) Dialog_Result(Result As Int)
    If Result = DialogResponse.POSITIVE Then
        If Checkbox2.Checked=True Then
            Msgbox2Async("This Will Override The Existing Data" , "Over-ride Design", "OK", "Cancel", "", Null,False)
        Else
            Msgbox2Async("This Will Add The Data To The Existing Data" , "Over-ride Design", "OK", "Cancel", "", Null,False)
        End If
        Wait For Msgbox_Result (Answ As Int)
        If Answ = DialogResponse.POSITIVE Then
            If Checkbox2.Checked=True Then
                EraseDesignData
            End If
            CGlobals.CreateOtherTables
           
           
            If Button1.Checked=True Then
                'Import CSV
                Table = SU.LoadCSV(fd.FilePath, fd.ChosenName, ",")
            Else IF Button2.Checked=True Then
                'Import Text
                Table = File.ReadList(fd.FilePath, fd.ChosenName)
            End If
           
            Dim Table2 As List
            Dim Items(), Item As String
            Table2.Initialize
           
            For i = 0 To Table.Size - 1
                Try
                If Button1.Checked=True Then
                    'CSV File
                    Items = Table.Get(i)
                Else
                    'Text File
                    Item=Table.Get(i)
                    Items =  Regex.Split(Chr(9),Item)
                End If
                Dim m As Map
                m.Initialize
               
                    Msgbox2Async(Items(2) & "   " & Items(3), "Import", "OK", "", "", Null,False)

                If IsNumber(Items(1))=True Then
                    If RButton1.Checked=True Then
                        'Horizontal Pi's
                        m.Put("No", Items(0)) 'You will need to replace the columns names with the correct names
                        m.Put("StartSV", Items(1))
                        m.Put("PiYCoord", Items(2))
                        m.Put("PiXCoord", Items(3))
                        m.Put("Radius", Items(4))
                        m.Put("TransIn", Items(5))
                        m.Put("TransOut", Items(6))
                    Else If RButton2.Checked=True Then
                        'Alignment Points
                        m.Put("No", Items(0))
                        m.Put("StartSV", Items(1))
                        m.Put("YCoord", Items(2))
                        m.Put("XCoord", Items(3))
                        m.Put("Radius", Items(4))
                        m.Put("Length", Items(5))
                        m.Put("Code", Items(6))
                        m.Put("Stake", Items(7))
                    Else If RButton3.Checked=True Then
                        'Vertical Alignment
                        m.Put("Stake", Items(0))
                        m.Put("VPiLevel", Items(1))
                        m.Put("Length1", Items(2))
                        m.Put("Length2", Items(3))
                        m.Put("Type", Items(5))
                    Else If RButton4.Checked=True Then
                        'Crossfalls
                        m.Put("Stake", Items(0))
                        m.Put("LeftCrossFall", Items(1))
                        m.Put("RightCrossFall", Items(2))
                    Else If RButton5.Checked=True Then
                        'Widths
                        m.Put("Stake", Items(0))
                        m.Put("LeftWidth", Items(1))
                        m.Put("RightWidth", Items(2))
                    Else If RButton6.Checked=True Then
                        'Edge Shift
                        m.Put("Stake", Items(0))
                        m.Put("LeftWidth", Items(1))
                        m.Put("LeftHeight", Items(2))
                        m.Put("RightWidth", Items(3))
                        m.Put("RightHeight", Items(4))
                    Else If RButton7.Checked=True Then
                        'Shoulders
                        m.Put("Stake", Items(0))
                        m.Put("LeftWidth", Items(1))
                        m.Put("LeftCrossFall", Items(2))
                        m.Put("RightWidth", Items(3))
                        m.Put("RightCrossFall", Items(4))
                    Else If RButton8.Checked=True Then
                        'Median
'                        m.Put("Stake", Items(0))
'                        m.Put("LeftWidth", Items(1))
'                        m.Put("LeftCrossFall", Items(2))
'                        m.Put("RightWidth", Items(3))
'                        m.Put("RightCrossFall", Items(5))
                    Else If RButton9.Checked=True Then
                        'Stake Offset
                        m.Put("Stake", Items(0))
                        m.Put("Offset", Items(1))
                    Else If RButton10.Checked=True Then
                        'Grade Offset
                        m.Put("Stake", Items(0))
                        m.Put("HorOffset", Items(1))
                        m.Put("VerOffset", Items(2))
                    End If
                    Table2.Add(m)
                End If
                Catch
                    Log(LastException)
                    'Msgbox2Async("Your File Is In The Wrong Format " , "Import", "OK", "", "", Null,False)
                    'Wait For Msgbox_Result (Answ As Int)
'                    If Answ = DialogResponse.POSITIVE Then
'                        Return
'                    End If
                End Try
            Next
                                   
            If RButton1.Checked=True Then
                'Horizontal Pi's
                DBUtils.InsertMaps(CGlobals.SQL1, "HorPi", Table2)
                ToastMessageShow("Horizontal Pi's Imported", False)
            Else If RButton2.Checked=True Then
                'Alignment Points
                DBUtils.InsertMaps(CGlobals.SQL1, "Align", Table2)
                ToastMessageShow("Alignment Points Imported", False)
            Else If RButton3.Checked=True Then
                'Vertical Alignment
                DBUtils.InsertMaps(CGlobals.SQL1, "VerPi", Table2)
                ToastMessageShow("Vertical Pi's Imported", False)
            Else If RButton4.Checked=True Then
                'Crossfalls
                DBUtils.InsertMaps(CGlobals.SQL1, "Crossfall", Table2)
                ToastMessageShow("Crossfalls Imported", False)
            Else If RButton5.Checked=True Then
                'Widths
                DBUtils.InsertMaps(CGlobals.SQL1, "Width", Table2)
                ToastMessageShow("Widths Imported", False)
            Else If RButton6.Checked=True Then
                'Edge Shift
                DBUtils.InsertMaps(CGlobals.SQL1, "Edge", Table2)
                ToastMessageShow("Edge-Shits Imported", False)
            Else If RButton7.Checked=True Then
                'Shoulders
                DBUtils.InsertMaps(CGlobals.SQL1, "Shoulder", Table2)
                ToastMessageShow("Shoulders Imported", False)
            Else If RButton8.Checked=True Then
                'Median

            Else If RButton9.Checked=True Then
                'Stake Offset
                DBUtils.InsertMaps(CGlobals.SQL1, "StakeOffset", Table2)
                ToastMessageShow("StakeOffsets Imported", False)
            Else If RButton10.Checked=True Then
                'Grade Offset
                DBUtils.InsertMaps(CGlobals.SQL1, "GradeOffset", Table2)
                ToastMessageShow("GradeOffsets Imported", False)
            End If
        End If
    End If
   
End Sub
]

On a different Activity, I open the Horizontal Alignment and see that the decimal values of the coordinates have changed. Any reason for that?

[
Sub Load_Hor
    HorNo.Clear
    ResultSet = CGlobals.SQL1.ExecQuery("SELECT No FROM HorPi")
    Rec=0
    Do While ResultSet.NextRow
        Rec=Rec+1
        HorNo.Add(ResultSet.GetString("No"))
    Loop
    Rec=Rec + 1
    HorNo.Add(Rec)
    HorNo.SelectedIndex = Rec-1
    ResultSet.Close            'close
End Sub

Sub HorNo_ItemClick (Position As Int, Value As Object)
    WorkItem = HorNo.SelectedItem
    Try
        Query = "SELECT * FROM HorPi WHERE No = ?"
        ResultSet =CGlobals.SQL1.ExecQuery2(Query, Array As String (WorkItem))
        ResultSet.NextRow
        HorStartSV.Text = NumberFormat2(ResultSet.GetString("StartSV"),1,3,3,False)
        HorYCoord.Text = NumberFormat2(ResultSet.GetString("PiYCoord"),1,3,3,False)
        HorXCoord.Text = NumberFormat2(ResultSet.GetString("PiXCoord"),1,3,3,False)
        HorRadius.Text = NumberFormat2(ResultSet.GetString("Radius"),1,3,3,False)
        TransIn.Text = NumberFormat2(ResultSet.GetString("TransIn"),1,3,3,False)
        TransOut.Text = NumberFormat2(ResultSet.GetString("TransOut"),1,3,3,False)
        CGlobals.StartStake = HorStartSV.Text
    Catch
        Clean_HorText
    End Try
    ResultSet.Close
End Sub
]

Any hint or help will be appreciated.
 
Top