Android Question Odd SQLite Query Result

Rob Rendle

Member
Licensed User
Longtime User
Evening People,

Thanks (again) for taking a moment to look at a slight problem for me.

This query works :-

B4X:
Sub U45IV_Click

Results.ResultTest = 45
Results.testtxt = "SELECT NAME FROM Rec WHERE CT = " & Results.ResultTest & curname & " ORDER BY NAME "
StartActivity("Results")

End Sub

When the user presses the ImageView, ResultTest (on the Results Module) is set to 45, testtxt (on the Results Module) is set to "SELECT NAME FROM Rec WHERE CT = "& Results.ResultTest & curname & " ORDER BY NAME"

This works fine, in my 'Results' Module I have the following :-

B4X:
cur = SQL1.ExecQuery(testtxt)

For i = 0 To cur.RowCount -1
    cur.Position = i
    CTLV.AddSingleLine(cur.GetString("NAME"))

Great, so as you can see, this will populate a listview with all entries where the column CT has the value of 45

Now..why doesn't this work?

B4X:
Sub VEIV_Click

Results.ResultTest= V 
Results.testtxt = "SELECT NAME FROM Rec WHERE VE = " & Results.ResultTest & curname & " ORDER BY NAME "
StartActivity("Results")
End Sub

Now, from what I can see, we should be getting SELECT NAME FROM Rec WHERE VE = V

But we're not, according to the errors, we're getting SELECT NAME FROM Rec WHERE VE = "ORDER BY NAME"

It's as if Results.ResultTest isn't being 'set' correctly (or at all)

It's set as a Process_Global on both modules (and for the first example it works just fine). V is also declared as a string < I'm guessing this is where the problem is. On the working example, we're just searching on numerical values, but on this we're searching for a letter.

Process Globals looks a little like this (on both modules)

Dim ResultTest="" As String
Dim V As String

Is this the issue? :)
 

Rob Rendle

Member
Licensed User
Longtime User
Thanks NJDude, I have the same line on another module and it launches results ok and populates a listview correctly

The error remains :(
 
Upvote 0

Rob Rendle

Member
Licensed User
Longtime User
Thanks for the heads up NJ

I got the query to the stage of where it's now sending correctly. My error was that V is not a string, the string is ResultTest="",

Added ResultTest="V" (have to play around with the spaces and quotes in the query, a lot!) and this did the trick.
 
Upvote 0
Top