Android Question how return search result row number b4xtable (b4a)

Mahares

Expert
Licensed User
Longtime User
B4XTable1.SearchField.Text = DateTime
You can't use DateTime as a variable as it is a reserved word. You need to be more clear and explain exactly what you want. Show your code.
Do you want to show rowids of visible rows when you type a search string in the search box or what??
 
Upvote 0

mhk1368

Member
You can't use DateTime as a variable as it is a reserved word. You need to be more clear and explain exactly what you want. Show your code.
Do you want to show rowids of visible rows when you type a search string in the search box or what?

B4XTable1.SearchField.Text ="id"

i want find all my row have the same id in first column and get second column value for plotting
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
i want find all my row have the same id in first column and get second column value for plotting
Use B4XTable1.BuildQuery. Here is an example:
B4X:
Dim o() As Object = B4XTable1.BuildQuery(False) 'no page limit
    Dim s As String ="SELECT c0, c1 FROM data WHERE c0 LIKE ?"    'c0 is first col, c1 is second
    o(0)=s
'    Dim s2 As String = $"%${B4XTable1.SearchField.Text}%"$  'you can also use the prefix and suffix
    Dim s2 As String = $"${B4XTable1.SearchField.Text}"$
    o(1)=Array As String(s2)
    Dim rs As ResultSet = B4XTable1.sql1.ExecQuery2(o(0), o(1))
'    Log(rs.RowCount)
    Do While rs.NextRow
        Log(rs.GetString("c0")  & "   " & rs.GetString("c1"))
    Loop
    rs.Close
 
Upvote 0

mhk1368

Member
Use B4XTable1.BuildQuery. Here is an example:
B4X:
Dim o() As Object = B4XTable1.BuildQuery(False) 'no page limit
    Dim s As String ="SELECT c0, c1 FROM data WHERE c0 LIKE ?"    'c0 is first col, c1 is second
    o(0)=s
'    Dim s2 As String = $"%${B4XTable1.SearchField.Text}%"$  'you can also use the prefix and suffix
    Dim s2 As String = $"${B4XTable1.SearchField.Text}"$
    o(1)=Array As String(s2)
    Dim rs As ResultSet = B4XTable1.sql1.ExecQuery2(o(0), o(1))
'    Log(rs.RowCount)
    Do While rs.NextRow
        Log(rs.GetString("c0")  & "   " & rs.GetString("c1"))
    Loop
    rs.Close
i checked it but not work
 
Upvote 0

mhk1368

Member
Use B4XTable1.BuildQuery. Here is an example:
B4X:
Dim o() As Object = B4XTable1.BuildQuery(False) 'no page limit
    Dim s As String ="SELECT c0, c1 FROM data WHERE c0 LIKE ?"    'c0 is first col, c1 is second
    o(0)=s
'    Dim s2 As String = $"%${B4XTable1.SearchField.Text}%"$  'you can also use the prefix and suffix
    Dim s2 As String = $"${B4XTable1.SearchField.Text}"$
    o(1)=Array As String(s2)
    Dim rs As ResultSet = B4XTable1.sql1.ExecQuery2(o(0), o(1))
'    Log(rs.RowCount)
    Do While rs.NextRow
        Log(rs.GetString("c0")  & "   " & rs.GetString("c1"))
    Loop
    rs.Close
I tried this but it did not work and rs.RowCount=0
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I tried this but it did not work and rs.RowCount=0
In that case, you need to zip and post your project or a small project and explain the exact issue. I am sure someone will figure it out and help you. Since you just became a member a couple of days ago, please follow the correct procedure to zip and post the project.
 
Upvote 0

mhk1368

Member
In that case, you need to zip and post your project or a small project and explain the exact issue. I am sure someone will figure it out and help you. Since you just became a member a couple of days ago, please follow the correct procedure to zip and post the project.
thanks
i solve my problem with this code and read from database not from table and make table from new data but don't know how to use variable string in my code?

Dim Msec As String=DateTime.Date(DateTemplate.Date)
Dim rs As ResultSet = sql.ExecQuery("SELECT TimeDb, TempDb FROM tblTemp WHERE TimeDb LIKE '%{Msec}%' ")
 
Upvote 0

mhk1368

Member
In that case, you need to zip and post your project or a small project and explain the exact issue. I am sure someone will figure it out and help you. Since you just became a member a couple of days ago, please follow the correct procedure to zip and post the project.
i used bottom code but cant find item: Msec=۱۱/۰۶/۲۰۲۲%



Dim Msec As String=DateTime.Date(DateTemplate.Date) & "%"
Log("Msec=" & Msec)
Dim txt As String
txt="SELECT TimeDb, TempDb FROM tblTemp WHERE TempDb LIKE ? "
Dim rs As ResultSet=sql.ExecQuery2(txt,Array As String(Msec))
 
Upvote 0
Top