Android Question Odd SQLite Query Result

Discussion in 'Android Questions' started by Rob Rendle, Apr 23, 2015.

  1. Rob Rendle

    Rob Rendle Member Licensed User

    Evening People,

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

    This query works :-

    Sub U45IV_Click

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

    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 :-

    cur = SQL1.ExecQuery(testtxt)

    For i = 0 To cur.RowCount -1
        cur.Position = i
    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?

    Sub VEIV_Click

    Results.ResultTest= V 
    Results.testtxt = 
    "SELECT NAME FROM Rec WHERE VE = " & Results.ResultTest & curname & " ORDER BY NAME "
    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? :)
  2. NJDude

    NJDude Expert Licensed User

    This line should be:
    thedesolatesoul likes this.
  3. Rob Rendle

    Rob Rendle Member Licensed User

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

    The error remains :(
  4. NJDude

    NJDude Expert Licensed User

    If you are declaring variable in Process_Globals you don't have to re-declare them on every activity, just reference them, in this case for what I can see the V variable is not holding any value.
    thedesolatesoul likes this.
  5. Rob Rendle

    Rob Rendle Member Licensed 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.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice