Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Value from SQL Server

Status
Not open for further replies.

schafjoe

Programmer
Dec 16, 2002
20
0
0
US
Everybody,
How do I return a value from SQL Server?

For example,

= SQLSETPROP(gnConnHandle, 'asynchronous', .F.)
= SQLEXEC(gnConnHandle, 'SELECT @@VERSION')

Thanks
 
Does this do it for you?

= SQLEXEC(gnConnHandle, 'SELECT @@VERSION AS Ver', cOut)

?cOut.Ver
 
schafjoe,

In the example you gave, you will get the required version number back in a cursor, which will have one row and one column. The name of the cursor will default to SQLResults, but you can optionally pass another name as the third parameter to SQLEXEC().

If the command that you are sending to the server is a stored procedure, you can retrieve its results in the form of output parameters, which are parameters that are passed by reference from VFP. If you are unfamiliar with output parameters, you should read up on how SQL Server handles parameters in stored procedures.

If the command you are sending includes a PRINT statement, you are out of luck, as these cannot return data to VFP. Similarly, if it has a RETURN statement, you will not be able to retrieve the returned value in VFP.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top