The problematic part is, you won't find any book covering how Cursoradapter can be used for remote databases, you have to read up that in the VFP help.
It's good to know that you have three main options:
1. Remote Views. You need a DBC for that, and the DBC has to have a connection object defining the connection to any remote database you can connect to via ODBC.
2. SQL Passthrough: SQL...() functions, which also work with ODBC connections. (Start with SQLStringConnect, SQLExec, and SQLDisconnect.
3. Cursoradapters set up for remote access.
Cursoradapters may use ODBC driver or OLEDB provider, while the first two options depend on ODBC driver.
Remote views may be easiest to set up both in regard of defining the query visually and defining them updatable, but the view editor is limited.
SQL Passthrough is easy for readonly queries and the only option to also execute longer scripts instead of just queries, ie. SQLExec enables you to create databases, tables, stored procedures etc. via DDL (data definition language) and also enable simple to complex queries you may also design visually within a visual query editor for the remote database, eg in MS SQL Server Management Studio. What's harder with SQLExec is to make the result cursor updatable so you can write back changes to the remote database via TABLEUPDATE().
Cursoradapters don't depend on the limitations of the view editor for remote views on the one side and on the other side enable an easier set up to be updatable, than SQL Passthrough does via the Cursoradapter builder. Bernard Bout extended the builder coming with VFP.
I use a mix of SQL Passthrough and Cursoradapters.
In any way you choose, you must learn the SQL dialect of the remote database, you cannot use VFP functions in queries, for example, which makes it a less simpler task to convert native data access to client/server. Even harder is to convert USE of tables or using the DE, there is no such thing for tables of remote databases, you have to make use of sql queries and you have to change your overall thinking about data access. You don't first show all data and let users then filter, you rather ask users what they search and then only query that. Also you don't (easily) have refresh of the viewed data. If you try simialr things as SET REFRESH with your view or cursoradapter cursors, you end up with more problems than the benefit of the live view on data. Client/Server rather means using your connection sparsely for reading and saving, not for refreshing and also not for writing each single change right away. What works better this way is multi user. It scales up better to work this way and you can even set up remote connections, so the database can be in the internet or cloud.
I used to run a course on client-server programming with VFP. It only gave an introduction to the subject. It didn't cover cursor adapters, because they hadn't been invented when I first developed the course. It only covered one back end (SQL Server). And it didn't go into much depth about the version of SQL used on the server.
Now, that was a solid, two-day course, supported by a 100-page manual and numerous examples that I developed in advance.
I'm only telling you this to give you an idea of how big the subject is. I don't mean to discourage you from learning more. Moving a VFP app from DBFs to a back-end database like SQL Server is often a worthwhile thing to do. But you must be prepared to put some effort into learning how to it. Simply asking here for some examples won't get you far, unfortunately.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
While that's true and especially for access to MSSQL, usage of OLEDB providers can give you access to other areas, not even databases, where OLEDB is the only option.
Since you specifically asked for SQL Server I could have skipped mentioning OLEDB, indeed.
Craig, I already admitted: "While that's true and especially for access to MSSQL...Since you (meaning alisaif) specifically asked for SQL Server I could have skipped mentioning OLEDB, indeed."
That was just to be covering what Cursoradapter can do in comparison with SQL Passthrough.
There already was no need to ask which provider I meant, but you asked and I answered with an example.
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.