[Gambas-user] Database example

charlesg charles at ...1784...
Sun Jun 14 14:57:43 CEST 2009


Hi,

I have extracted what I need from the database example. I can even get it to
do exactly what I want. But, in truth, I do not understand how it works
exactly.
'===================================================
' FMain.class
PUBLIC $hConnLocl AS NEW Connection
PUBLIC $resData AS Result
'--------------------------------------------------------
PUBLIC SUB Form_Open()
  WITH $hConnLocl
    .type = "sqlite3"
    .Name = "/home/charles/sqlite3/locl.sqlite"
  END WITH 
  $hConnLocl.Open()
  $resData = $hConnLocl.Exec("select * from hist")
END
'---------------------------------------------------------
PUBLIC SUB btnRun_Click()
  DIM hForm AS FRequest
   
  hForm = NEW FRequest($hConnLocl, $resData)
  hForm.show
END
'===================================================
' FRequest.class  
PRIVATE $hConnlocl AS Connection
PRIVATE $rData AS Result
'---------------------------------------------------------
PUBLIC SUB _new(hConnlocl AS Connection, rData AS Result)
  DIM hField AS ResultField
  DIM iInd AS Integer
  
  $hConnlocl = hConnlocl
  $rData = rData
  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 = 60
    END WITH 
    INC iInd
  NEXT
  tbvData.Rows.Count = $rData.Count
END
'---------------------------------------------------------
PUBLIC SUB tbvData_Data(Row AS Integer, Column AS Integer)
  $rData.MoveTo(row)
  tbvData.Data.text = Str($rData[tbvData.Columns[column].text])
END
'===================================================

My lack of understanding hinges around:
1.	hForm = NEW FRequest($hConnLocl, $resData)
2.	$hConnlocl = hConnlocl
  	$rData = rData
3.	The help says _data is called when the tableview 'needs data'. At what
point in the code does it need this data?

Any fog elimination welcomed.

rgds

-- 
View this message in context: http://www.nabble.com/Database-example-tp24021356p24021356.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list