Android Question jdbc select with AnotherDatePicker value date

I was able to execute the query by passing the AnotherDatePicker parameter. But the query returns empty filtering by the date entered, but there is data in the database, from my back I query successfully. What could be wrong with this query? And how do I test the result of a jdbcresult?, if it is empty?

Try
Dim sqlquery As String
DateTime.DateFormat = "yyyyMMdd"
Private sDate = DateTime.Date(dtp1.date) As String
Log(sDate)

sqlquery = "select count(distinct(pedido)) as qtped, sum(qtde * valor) as valped from itens_pedido where data = '" & sDate & "'"
sqlquery= sqlquery & " and status= 'P' "
Dim SenderFilter As Object = conexao.sql1.ExecQueryAsync("SQL", sqlquery, Null)
Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As JdbcResultSet)
If Success Then
If rs.NextRow Then
Do While rs.NextRow
 
Upvote 0
Yes, Erel, thank´s. My problem now is get date value from AnotherDatePicker for use in query, example:

dim mydate as string = AnotherDatePicker.date ?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
My problem now is get date value from AnotherDatePicker for use in query, example:
Do not use anotherDatePicker. Use B4XDateTemplate of xui views. Here is a complete example.
B4X:
Sub Globals
    Private Dialog As B4XDialog   'need XUI Views checked (internal lib)
    Private DateTemplate As B4XDateTemplate
    Private XUI As XUI 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dialog.Initialize (Activity)  'use Root instead of activity if you preferably use a B4XPages project
    Dialog.Title = "Select a date"
    DateTemplate.Initialize
    DateTime.DateFormat= "yyyyMMdd"
    Wait For (Dialog.ShowTemplate(DateTemplate, "", "", "CANCEL")) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        Dim mydate As String = $"${DateTime.Date(DateTemplate.Date)}"$
        Log(mydate)
    End If
End Sub
Show us your parameterized query code. I think you could use some help there too.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…