|
|||||||||||||||||
How to Interact with data in an Alpha Five Table (.dbf file) on a Server from a Desktop ApplicationAssume you have a web application created with Alpha Five. The server is running the Alpha Five Application Server and has several Alpha Five tables (i.e. .dbf files) on it. You also have a desktop application, and you want to be able to insert, edit and delete records in those tables from your desktop application. Here is how this can be done. The first step is to create .a5w pages on the server that will do the work of inserting, updating or deleting records in your tables. Having created those pages, you can then 'execute' those pages from your desktop application using the http_get_page2() function. Assume that the 'customer' table from Alphasports is on your server and you want to enter a new record into this table. First, you would create a new page on the server called (say) 'enterCustomer.a5w'. The code in this page would look like this: <%a5 'define default values for
any variables that are NOT submitted when the page is called 'enter a new record 'report the results Notice that this .a5w page is all Xbasic code. It does not display any HTML. The key aspects of the page are: 1. All of the variables are dimmed with a default value. This means that if the variable is not defined in the query string that calls the page, the variable will still have a value. 2. The page response (is either 'success' To test this page from the Interactive window in Alpha Five, you would type this: data = "firstname=selwyn&lastname=rabins&company=alphasoftware" The 'data' variable is simply a list of name/value pairs giving values to each of the fields in the new record that you want to update. It is in the standard format of URL query string. The 'baseurl' variable just points to the 'enterCustomer.a5w' page on our server. We then use the http_get_page2() function to execute the page, passing in the data as part of the URL. The response we get from the server is 'success', indicating that the new record was added to the table. Now, for the next step we can create an Xdialog on in our desktop application to prompt the user for the field values. The Xdialog will then construct the URL and call the http_get_page2() function. Here is the Xdialog (simplified to prompt for just a few fields in the record). Notice that we don't prompt for the customer_id field because this is an auto-increment field - its value is set automatically when a new record is added. dim firstname as c
|
|||||||||||||||||
|
|||||||||||||||||