Android Question What is res.Rows.Size for?

aldanan

New Member
i need to insert a same name but this code block me. sorry i dont know what is res.rows size is all about but when i delete it it doesnt send a response to the database any heald? its like: Last_Name='White' and i insert into another record with also name White it shows name already used please use another



B4X:
Sub GetSelectedRecord (NameSelectedItem As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("selectedItem", Array(NameSelectedItem))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    ProgressDialogShow("Loading...")
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        req.PrintTable(res)
        Log(res.Columns)
        For Each row() As Object In res.Rows
            
            If Main.Status = "U" Then
                Dim oBitMap As Bitmap
                Dim buffer() As Byte
                buffer = row(res.Columns.Get("image"))
                oBitMap = req.BytesToImage(buffer)
            
                item_id = row(0)
                Last_Name.Text = row(1)
                First_Name.Text = row(2)
                Middle_Name.Text = row(3)
                Student_ID.Text = row(4)
                Email.Text = row(5)
                Birthday.Text = row(6)
                Age.Text = row(7)
                Address.Text = row(8)
                ImageViewIU.Bitmap = oBitMap
                
                Dim Delta, Height, Width As Int
                If oBitMap.Width / oBitMap.Height > ImageViewIU.Width / ImageViewIU.Height Then
                    Height = oBitMap.Height / oBitMap.Width * ImageViewIU.Width
                    Delta = (ImageViewIU.Height - Height) / 2
                    ImageViewIU.Height = Height
                    ImageViewIU.Top = ImageViewIU.Top + Delta
                Else
                    Width = oBitMap.Width / oBitMap.Height * ImageViewIU.Height
                    Delta = (ImageViewIU.Width - Width) / 2
                    ImageViewIU.Width = Width
                    ImageViewIU.Left = ImageViewIU.Left + Delta
                End If
            Else
                If res.Rows.Size > 0 Then
                    ProgressDialogHide
                    Msgbox("Name already used, please use another name !","Failed")
                End If
            End If
        Next
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    
    If res.Rows.Size = 0 Then
        Dim bufferI () As Byte
        bufferI = CreateRequest.ImageToBytes(ImageViewIU.Bitmap)
    
        Dim CAge As Int = Age.Text
        InsertRecord(Last_Name.Text,First_Name.Text,Middle_Name.Text,Student_ID.Text,Email.Text,Birthday.Text,CAge,Address.Text,bufferI)
    End If
    
    ProgressDialogHide
    j.Release
End Sub
 
Top