[Gambas-user] MySQL and general data issues
Keith Clark
keithclark at ...2185...
Tue Mar 2 21:39:52 CET 2010
On Mon, 2010-03-01 at 23:36 +0100, Charlie Reinl wrote:
> Am Montag, den 01.03.2010, 16:22 -0500 schrieb Keith Clark:
> > I am trying to access some data using the documentation "A Beginner's
> > Guide to Gambas" and I've gotten this far:
> >
> > PUBLIC SUB SearchButton_Click()
> >
> > DIM $Query AS String
> > DIM $Result AS Result
> > DIM iIndex AS Integer
> > DIM hField AS ResultField
> >
> > DatabaseConnection.Connect()
> >
> > $Query = "select products.products_model as ISBN,
> > products_description.products_name AS Title,
> > manufacturers.manufacturers_name AS Author,
> > categories_description.categories_name AS Genre,
> > products.products_quantity AS Quantity FROM products Left join
> > products_description on products.products_id =
> > products_description.products_id Left join manufacturers on
> > products.manufacturers_id = manufacturers.manufacturers_id Left join
> > products_to_categories on products.products_id =
> > products_to_categories.products_id Left join categories_description on
> > products_to_categories.categories_id =
> > categories_description.categories_id where
> > products_description.products_name LIKE '%blue%'"
> > $Result = DatabaseConnection.$Con.Exec($Query)
> > TitleSearchTableView.Rows.count = 0
> > TitleSearchTableView.Columns.Count = $Result.Fields.Count
> > FOR EACH hField IN $Result.Fields
> > WITH hField
> > TitleSearchTableView.Columns[iIndex].Text = .Name
> > TitleSearchTableView.Columns[iIndex].Width =
> > WidthFromType(TitleSearchTableView, .Type, .Length, .Name)
> > END WITH
> > INC iIndex
> > NEXT
> >
> > But I get an error:
> >
> > Unknown identifier: WidthFromType
> >
> > Not sure what I'm doing wrong here. Maybe just not understanding it
> > well enough yet.
> >
> > Keith
>
> Salut Keith,
>
> you have to look for the function "WidthFromType" which returns the
> width for the field. Should be in the example.
> If you can't find it, a workaround could be this:
> replace : TitleSearchTableView.Columns[iIndex].Width =
> WidthFromType(TitleSearchTableView, .Type, .Length, .Name)
> by
> TitleSearchTableView.Columns[iIndex].Width = 50
>
> Or/and look if you don't have a typo !?
>
Ok, I have it working now, but the table view box never shows anything
but one long blank cell.
I went on to create a fill routine as follows:
FOR iRowIndex = 0 TO $Result.Count - 1
$Result.MoveTo(iRowIndex)
FOR iColumnIndex = 0 TO $Result.Fields.Count - 1
PRINT "Here is Column" & iColumnIndex
PRINT "Here is the data" &
Str($Result[TitleSearchTableView.Columns[iColumnIndex].text])
TitleSearchTableView.Data.Text =
Str($Result[TitleSearchTableView.Columns[iColumnIndex].text])
NEXT
NEXT
It seems to be returning the correct number of rows/columns and the
correct data, just not in the table view box.
More information about the User
mailing list