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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql Server

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

How can I use Ms Sql Server or My Sql instead of native VFP Table?
How can I save records?
How can I retrieve records? etc..

Please guide with examples.

Thanks

Saif
 
This is a very large and wide-ranging topic, where this board is better at answering specific questions.

You can start with the VFP help topic "Walkthrough: Retrieving Data from Different Data Sources". See if you come up with some specific questions.
 
That's a huge question. Whole books have been written on the subject. It's difficult to answer in a few sentences.

I suggest you do the following:

- Study the VFP Help topic "Planning Client/Server Applications";

- Install the SQL Server Developer Edition, or SQL Server Express, and read its documentation;

- Get hold of "Client-Server Applications with Visual FoxPro and SQL Server 7.0", from Hentzenweke Publishing.

- Come back here when you have specific questions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I second both Dan and Mike.

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.

Bye, Olaf.
 
Just to drive the point home ....

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)

Visual FoxPro articles, tips and downloads
 
Thanks for the time sharing, I will definitely go through these points.

Saif
 
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.

Bye, Olaf.
 
For example the Microsoft OLE DB Provider for Microsoft Active Directory Service.

Bye, Olaf.
 
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.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top