>I ve got a connection to my MSDE database using
>
>gnConnHandle = SQLCONNECT('myServer', 'me')
>
>
>I should be connected to a database called myDB and there should be a table called myTable. How do I select all records from that table into a cursor called myCursor?
>
>
>select * from myDB!myTable! into cursor myCursor
>
Hi Einar,
Cetin showed you how to use the SQLExec statement. When I'm making really long SQLExec statements I use VFP's text merge:
lcParamter = "SomeParameter"
TEXT TO lcSQLStatement TEXTMERGE NOSHOW
SELECT * FROM MyTable
WHERE SomeColumn = <<lcParameter>>
ENDTEXT
SQLExec(nConnection, lcSQLStatement, "ResultCursor")
Using the text merge makes coding the statements much easier than concatenating strings of code. Also, if you have the SQL Server client tools (Query Analyzer) then you can paste the text you've just generated right into the QA window and test there. (
_ClipText = lcSQLStatement
)
For development I do the SQLConnect() and SQLExec() right in the Command window until I get the results I want.
Besides using SQL Pass-through you can use a remote view, or a parameterized remote view. You can also make the cursor that results from the SQLExec into an updatable cursor. Each approach has its good points and bad points.