Register to post in forums, or Log in to your existing account
 

Database Demo [[DatabaseDemo]] 
This demonstration application uses the native database support in zApp to browse any database. Click the Connect button, then use the Connection dialog to select a database driver and then the server or database to connect to. A combo-box is then populated with all of the tables in this database, and you can select a table from this list, or enter any SQL query in the text box and click the Query button. The results of the query are shown in the data grid.

This application not only demonstrates how easy it is to access databases in zApp, but it also showcases the powerful visual Grid component that is part of zApp. This component can be used for any sort of grid-list or list-like information display and can be highly customized. It is used in many of the demonstration applications that come with zApp. If you have used Grid components in other programming languages, you will be amazed how easy the Grid in zApp is to use, and how powerful it is.

Here is the zApp XML source code for this application:
Code:
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE zapp [
  <!ENTITY AppTitle "zApp Demo: Database browser">
  <!ENTITY AppAuthor "Zugg Software">
  <!ENTITY AppVersion "1.0">
  <!ENTITY AppURL "http://www.zuggsoft.com/">
  <!ENTITY AppImage "ZAPP">
  <!ENTITY AboutBox SYSTEM "aboutbox.xml">
  ]>
<zapp>
  <splash color='#C4D2ED'>
    <image image='zapp' deltaleft='8' deltatop='8'/>
    <label align='Client' bevelouter='Lowered' autoleft='true' deltaleft='8' width='-8' height='-8' gradienttype='FullVertical' color='#C4D2ED' colorto='#7E98CB'><![CDATA[<b>&AppTitle;</b><br><br>
Version &AppVersion;<br><br>
by &AppAuthor;]]></label>
  </splash>
  <toolbar name='mainmenu'>
    <menu caption='&amp;File'>
      <item action='_FileExit'/>
    </menu>
    <menu caption='&amp;Edit'>
      <item action='_EditCut'/>
      <item action='_EditCopy'/>
      <item action='_EditPaste'/>
    </menu>
    <menu caption='&amp;View'>
      <item caption='Normal' script='core.themeindex = -1'/>
      <item caption='Aqua' script='core.theme = "aqua"'/>
      <item caption='Watercolor' script='core.themeindex = 2'/>
      <item caption='Flat' script='core.theme = "Flat"'/>
      <item caption='Standard' script='core.theme = "Standard"'/>
      <item caption='UltraFlat' script='core.theme = "UltraFlat"'/>
      <item caption='Office11' script='core.theme = "Office11"'/>
      <item caption='OfficeXP' script='core.theme = "OfficeXP"'/>
      <item action='_ThemeSelect'/>
    </menu>
    <menu caption='&amp;Help'>
      <item caption='&amp;About' script='core.execwindow( "About")'/>
    </menu>
  </toolbar>
  <toolbar name='maintoolbar'>
    <navigator/>
  </toolbar>
  <window name='main' caption='&AppTitle;' width="640" height="480">
    <menu Name='EditMenu' caption='&amp;Edit'>
      <item action='_EditCut'/>
      <item action='_EditCopy'/>
      <item action='_EditPaste'/>
    </menu>
    <connection name='DBConn'>
      <query name='DBQuery'>
        <datasource name='DBSource'/>
      </query>
    </connection>
    <dock position='top'>
      <toolbar name='mainmenu'/>
      <toolbar name='maintoolbar'/>
    </dock>
    <panel align='top' height='22'>
      <button action='_DBConnect' align='left' width='100' menu='EditMenu'>
        SQL.Text = ""
        DBSource.Active = false
        core.ExecuteAction
        if (DBConn.Connected) then
          main.Caption = "Connected to: " &amp; DBConn.Filename
        else
          main.Caption = "Not connected"
        end if 
      </button>
      <combo.tables name='TableList' align='left' hint='Select Table' datasource='DBSource'>
        <script event='onchange'>
          DBSource.Active = false
          if (TableList.Text = "") then
          else
            DBQuery.Text = TableList.Text
            DBSource.Active = true
          end if
        </script> 
      </combo.tables>
      <button caption='Query' align='right' image='dbquery'>
        DBSource.Active = false
        DBQuery.Text = SQL.Text
        DBSource.Active = true
      </button>
      <edit name='SQL' caption='SQL:' align='client' deltaleft='40'/>
    </panel>
    <grid name='DBGrid' align='client' datasource='DBSource'/>
    <statusbar name='Status' align='bottom'/>
    <script>
    </script>
  </window>
  &AboutBox;
</zapp>

Notice that no code is needed to control the Grid component. Simply set the DataSource property of the Grid and zApp does all the rest.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net