Web Connection
Read and write Data with REST-Api from and to MS-SQL
Gravatar is a globally recognized avatar based on your email address. Read and write Data with REST-Api from and to MS-SQL
  Hans-Peter Grözinger
  All
  Feb 10, 2026 @ 01:00am

Hello together,

I want to replace a VFP project with a SOAP connection to the DBF tables with a REST API connection to an MS SQL Server.

I'm using West-Wind Web Connection for this.

Are there any suitable examples I could use as a basic framework?

Gravatar is a globally recognized avatar based on your email address. re: Read and write Data with REST-Api from and to MS-SQL
  Hans-Peter Grözinger
  Rick Strahl
  Feb 10, 2026 @ 10:29am

Step by Step: Creating a JSON REST Service

As a beginner in setting up a REST API server, I've already worked through this chapter.

Unfortunately, it doesn't include any examples of how to access the SQL server, for example, using the wwSQL class.

So far, I haven't found out whether this class can read the connection string directly from a configuration XML file.

My question is, where in the code should I create the wwSQL class, and can I read the connection string via a wwSQL method?

Gravatar is a globally recognized avatar based on your email address. re: Read and write Data with REST-Api from and to MS-SQL
  Rick Strahl
  Hans-Peter Grözinger
  Feb 11, 2026 @ 12:13pm

You should set up wwSql in your server startup. There's an oSQL property on your wwServer instance and you can read the configuration information there. You can create a connection string in the server configuration files (yourApp.ini).

There are examples of this in the default installer and I believe in the generated classes in the Load() method do this but it's commented out by default.

Something like this:

*** Load up any SQL Connections
#IF WWC_USE_SQL_SYSTEMFILES
	THIS.oSQL = CREATE("wwSQL")
	IF !THIS.oSQL.Connect(THIS.oConfig.cSQLConnectString)
	   MESSAGEBOX("Couldn't connect to system SQL Service. Check your SQL Connect string",48,"Web Connection")
	   CANCEL
    ENDIF
    this.oSql.EnableUnicodeToAnsiMapping(.T.)
#ENDIF

You can remove the conditional around the code to always have it work.

Read up on how the configuration handling works. You can create multiple connections and multiple configuration values for each connection if necessary but you'll need to add any other sql instance configuration settings explicitly.

To use you can then use:

*** In a Process method 
lnRecs = Server.oSql.Execute("select * from customers")

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Read and write Data with REST-Api from and to MS-SQL
  Hans-Peter Grözinger
  Rick Strahl
  Feb 13, 2026 @ 01:39am

Hello Rick, that helps me for a good start.

Thanks a lot.

© 1996-2026