[Gambas-user] Database example query

Frank H Aldridge franka at iway.na
Fri Sep 28 14:22:53 CEST 2018


I am an absolutely new user of Gambas, 76 years old and only using it to
write simple self-use programs. I bought the e-book Beginners Guide to
Gambas, Revised edition from Amazon and as a consequence it does not have
the cd that would have been included with the hard copy.

I am using Ubuntu 18.4 and Gambas 3.11.90 together with SQLite.

Because I don't have the cd I decided to "create" the Database1 program
described in the book under "The Database Example Program". I have created the main form as well as the FRequest form, both with their various
controls.

On FMain (I noticed that you cannot change the name of the Main form) I
placed a Textbox at the bottom in a Frame called SQL request.

During the instructions detailing how the program "works" there is the
following quote:

"we set the enabled properties for both program forms to TRUE and place some default text in the SQL request box at the bottom of the FMain form:

frmDatabase.Enabled = TRUE
frmRequest.Enabled = TRUE
txtRequest.Text ="Show Tables"

1. At this point my problem is that there are no forms called   frmDatabase or frmRequest.

2. My next problem is that the Textbox does not accept multi-lines.

The code for the "RUN Button" (next to the SQL Request text box is:

Public Sub btnRun_Click()

    Dim rData As Result

    Dim hForm As FRequest

    rData = $hConn.Exec(txtRequest.Text)
    hForm = New FRequest($hConn, rData)
    hForm.Show

    Catch
      Message.Error(Error.text)

      End

3. When I click on the "Run" button a message comes up stating: Query
failed: near "Show Tables"; syntax error. (I have only entered this oneline due to 2 above.

If I blank the Textbox for the SQL query and insert a SQL query directly
into the line:
rData = $hConn.Exec("Select * from Test") instead of (txtRequest.Text)then I get the message:

Cannot exec request
Unknown symbol 'Width' in Class 'Font'
OK

Clicking OK brings the message:
'Not enough arguments'

I believe that the above two messages come from the following code under the FRequest form.

Private Sub ReadData()


    Dim hTable As Table
    Dim hField As ResultField
    Dim iInd As Integer

    Inc Application.Busy

    tbvData.Rows.count = 0
    tbvData.Columns.Count = $rData.Fields.Count

    For Each hField In $rData.Fields
      With hField

        tbvData.Columns[iInd].Text = .Name

        tbvData.Columns[iInd].Width = WidthFromType(tbvData, .Type,.Length,.Name)

        End With

        Inc iInd

        Next

        tbvData.Rows.Count = $rData.Count

        Finally

          Dec Application.Busy

          Catch
            Message.Error("Cannot exec request" & "\n\n" & Error.Text)
           End

Can anybody who may have this book and the CD perhaps throw some light on
what may be causing the problems?

-- 
Frank H Aldridge
P.O. Box 3696
c/o Kiaat & Bottle Tree Streets
Ext. 15
Swakopmund
+264(0)811248922



More information about the User mailing list