Android Question RDC - SQL Server - Not Returning Rows

Discussion in 'Android Questions' started by Stealth Pyro, Jan 22, 2015.

  1. Stealth Pyro

    Stealth Pyro Member Licensed User

    I'd like to start by saying that I just bought B4A a week or two ago and I find it's quite an amazing IDE. It has an outstanding community and I hope a big future.

    I just set up the "new" RDC framework into my app with the jtds driver, and I am having an issue that should be quite easy to resolve.

    Communication between my client and server is definitely working. The problem is that it is not returning the rows (in this case, just a single row) that it should return. I'm using simple a stored procedure that receives 2 parameters (for simplicity's sake, let us assume these are user and password) and returns 8 columns. The stored procedure definitely works on SQL Server's end (executing it and passing it the parameters returns the exact row I'm expecting in SQL Server Manager), and I can see the names of all 8 columns in my client's result table during debugging. By retrieving the 8 column names, I believe that means the parameters were correctly received, but something else must be going on.

    This is my login button click event. It initializes the DBCommand and sends it to jtds with the text in txtEmail and txtPassword views as parameters (step debugging shows these values being passed fine).

    Code:
    Sub btnLogin_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = 
    "select_login"
    cmd.Parameters = 
    Array As Object(txtEmail.Text, txtPassword.Text)
    reqManager.ExecuteQuery(cmd, 
    0"login")
      
    End Sub
    This is my JobDone event. Didn't really change too much in it from the RDC example by Erel. When this reaches the line "For Each records() As Object In result.Rows" it skips the enclosing block that retrieves info from the single row that should be in "result", seemingly because there is no row in result. The line "Log(name)" which should print the string "name" to the log is not being executed either (obviously since it is within the for loop that isn't being entered). It does print the "HandleJob:##" message to the log.

    Code:
    Sub JobDone(Job As HttpJob)
       
    If Job.Success = False Then
         
    Log("Error: " & Job.ErrorMessage)
       
    Else
         
    If Job.JobName = "DBRequest" Then
           
    Dim result As DBResult = reqManager.HandleJob(Job)
           
    If result.Tag = "login" Then 'query tag
             For Each records() As Object In result.Rows
                
    Dim name As String = "name" + records(result.Columns.Get("UserID")) 'or records(result.Columns.Get("name"))
               'Dim name As String = records(0) 'or records(result.Columns.Get("name"))
               Log(name)
             
    Next
           
    End If
         
    End If
       
    End If
       Job.Release
    End Sub
    This is the SQL Server command in my jtds config. Is this the correct syntax for executing a stored procedure? I was previously getting syntax errors in my log regarding @P0 (first parameter), and after a little trial and error finished with the line below, which is not giving any log errors.
    Code:
    sql.select_login=exec sp_Login [UserID], [Password]
    Thanks in advance for the help... I'm sure it's a ridiculous little typo or bit that I'm missing.
     
    Last edited: Jan 22, 2015
  2. Stealth Pyro

    Stealth Pyro Member Licensed User

    Solved.

    I changed the sql command in the jtds config to the same syntax you would use in SQL Server. I can't really say why I insisted on this RDC having some different syntax.

    Code:
    sql.select_login=EXEC sp_Login @UserID = ?, @password = ?
     
    Last edited: Jan 22, 2015
    Erel likes this.
Loading...
  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