Table

Q:

what command I use to see if a table is open and what cursors are in use. I tried used(“table”), but it did not appear to work.

A:

Yes, USED(“alias-name” | cursor-number), specifying the alias name or the cursor/workarea number – returns .T. or .F.

Also INUSE(“alias-name”) – returns .T. or .F.

Or SELECT(“alias-name”) – returns 0 or the cursor/workarea number if open.

Did USED() return an error or just not the result you were expecting?


Let’s say you want to encrypt a table. In Lianja this uses DES3 encryption. This uses 3 keys which, together, provide quite decent security. To use it securely, and agilely, you will want to avoid putting the actual keys in your code. There are two pieces of information you need to have in mind:

1. each key is a max length of 8 chars
2. to use the keys contained in a .h file and #included you will need to macro-expand them. This is different than VFP, where bracketing them in square brackets [ and ] macro expands them, even inside a string. In Lianja it goes like this (for #define’s vars of Key1, Key2, and Key3):

encrypt mytable key “&(key1),&(key2),&(key3)”

The nice part of doing it this way, rather than defining a variable, is that examining memory will give the observer no clue as to the actual keys. Which observer? That’s why we concern ourselves with security — we don’t know who that might be.

This particular use is for a table used to store connection strings across multiple applications in one project. The name method of using &() to macro-expand within strings can be used to create the connection string without ever creating a memory variable holding the connection string.

Now, the astute observer will note that the .dbo file does in fact contain the key1, 2 and 3 information at the top of the file (where the #include was). True enough: if the bad guys get on your server, your security is toast. Which is why a) mobile apps can be more secure than desktop apps, especially if b) you configure your network with security in mind (I am no expert on the matter, but the essentials are easy to understand).


Q:

On a page with a canvas section with controls (TextBox, etc.) bound to a fields from a record on a table in my database, if the user makes changes to the data and then chooses to revert (not save the changes), what can I do to roll back the changes and not commit them to the table in the database?

A:

needed to call the Cancel() method before leaving the page. Apparently, just leaving the page without calling the Cancel() method automatically commits the data.

A2:

Lianja uses record buffering which means changes will be automatically committed if you move off the current record while editing. Closing the page would move the record pointer and would, therefore, commit any changes.


Styling desktop BROWSE

I’ve had a few folks asking me how to style grids and BROWSE. I’ve added support for CSS styling of BROWSE in Lianja 3.1.

As stated in the roadmap:

  • Added STYLE “text” as a BROWSE keyword. The “text” should be CSS. It may be a reference to a filename.css containing the CSS. This may be prefixed with “app:/filename.css” or “lib:/filename.css” which causes the file contents to be read and applied as CSS.

Name:  Screen Shot 2016-10-10 at 10.24.15 AM.jpg Views: 44 Size:  108.7 KB

Grid sections can be styled already. See CSS below.

Code:
open database southwind
use example
browse noactionbar ;
            style "* { selection-color:yellow; ;
                          selection-background-color:black; ;
                          gridline-color:green; ;
                          background:black;color:yellow; ;
                        } ;
                        QTableView::item { background:lightgreen; } ;
                        QHeaderView::section { background-color:green;color:white;border:0px; } "

Custom VFP Section and use the “Browse” command.

Desktop client only. It’s VFP browse embedded in a page.


Use SET KEY to limit the range of records you can access in a table. The table must be indexed, and the index key value or values you include must be the same data type as the index expression of the master index file or master tag.
Issue SET KEY TO without any additional arguments to restore access to all records in the table.

SET KEY TO [eExpression1 | RANGE eExpression2 [, eExpression3]] [IN cTableAlias | nWorkArea]


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.