Unable to display data to grid from stored procedure in VFP

339 views Asked by At

I want to display the result from my SP, but it does not display any

I already validated my query and it does return a row of results

Here is my code:

cn=SQLCONNECT("db", dbuser,dbpassword)
IF cn>0 then
    q=SQLEXEC(cn,"execute ListOfRepostEntries ?br1")
    q=SQLDISCONNECT(cn)
    IF q>0 then     
        thisform.grdRepostEntries.RecordSource=q
        thisform.grdRepostEntries.Refresh()
    ELSE
        MESSAGEBOX("Unable to execute query.",64,"Message")
    ENDIF
ELSE
    MESSAGEBOX("There was a problem connecting to the server.",64,"Message")
ENDIF
1

There are 1 answers

1
DRapp On BEST ANSWER

SQLExec() is used to run a query or stored procedure, but typically uses a THIRD parameter to give the alias result set upon return. As you have it, you are giving it the connection handle and the query to execute. The "Q" value you are getting back is only a status if it executed correctly or not.

Try changing slightly to

  q=SQLEXEC(cn,"execute ListOfRepostEntries ?br1", "myLocalAlias" )
    q=SQLDISCONNECT(cn)
    IF used( "myLocalAlias" ) 
        thisform.grdRepostEntries.RecordSource = "myLocalAlias"
        ...