SQL queries of a remote server from a Web Browser

This forum is for posting of useful information
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

SQL queries of a remote server from a Web Browser

#1 Post by rdonnay »

I wrote a few modifications to my SqlQuery program so it can be started as a Web Server.

I then added a new function to eXpress++ name DC_WorkArea2Html().

With this new code, I can now query data on a remote server by entering a SQL statement in a web browser.

This is the HTML form:

Code: Select all

<form action="http://192.168.0.53:8001/sqlservice/query">
Enter SQL SELECT Statement:<br>
<textarea rows=4 cols=100 name="sql">
select mednum as Medallion, Make, Model, Type, Fuel from mn_mdn where Left(make,4) = 'Ford'
</textarea>
<p>
<input TYPE="submit" NAME="SqlStatement" VALUE="Run Sql!">
</form>
I added a few new features to SqlQuery to use the command-line interface to send the query statement and produce an output from the workarea as HTML, XLS or CSV.

This output is then returned to the web browser, which can be on a tablet or a phone.

If you are using SqlQuery and have an interest in this capability, please let me know.
I would like to improve on this and make it more robust.

This uses the HttpEndPoint and WebHandler features of Xbase++ 2.0 and is very simple to implement with a few lines of code.

Look at how the changes to the command line interface are used to invoke SqlQuery to run the SQL statement and produce the output:

Code: Select all

METHOD SqlService:query( cSql )

LOCAL cParams, cHtml

cParams := '/co:ADS_1 /sq:"' + cSql + '" /ee:reply.htm'

Runshell(cParams,'sqlquery.exe')

IF File('reply.htm')
  cHtml := MemoRead('reply.htm')
ELSE
  cHtml := 'Cannot run your query'
ENDIF

RETURN cHtml
The eXpress train is coming - and it has more cars.

Post Reply