[Gambas-user] MySQL and general data issues
Keith Clark
keithclark at ...2185...
Tue Mar 2 22:49:03 CET 2010
On Tue, 2010-03-02 at 22:44 +0100, M. Cs. wrote:
> I'm using sqlite, and I think the querry should look like:
> DIM answer AS Result
> DIM querry As String
> ...............................
>
> querry="SELECT.........;"
> answer=YourConnection.Exec(querry)
> FOR EACH answer
>
> do what you want.....
>
> NEXT
Well, I have this now:
PUBLIC $Result AS Result
PUBLIC SUB SearchButton_Click()
DIM $Query AS String
'DIM $Result AS Result
DIM iIndex AS Integer
DIM hField AS ResultField
DIM iRowIndex AS Integer
DIM iColumnIndex AS Integer
DatabaseConnection.Connect()
$Query = "select products.products_model,
products_description.products_name, manufacturers.manufacturers_name,
categories_description.categories_name, products.products_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
iIndex = 0
'PRINT $Result.Fields.Count
'PRINT $Result.Count
FOR EACH hField IN $Result.Fields
WITH hField
'PRINT .Name; ": "; .Type; " "; .Length
TitleSearchTableView.Columns[iIndex].Text = .Name
TitleSearchTableView.Columns[iIndex].Width =
WidthFromType(TitleSearchTableView, .Type, .Length, .Name)
END WITH
INC iIndex
NEXT
PRINT "Results: " & $Result.Count
PRINT "Fields: " & $Result.Fields.Count
FOR iRowIndex = 0 TO ($Result.Count - 1) STEP 1
FOR iColumnIndex = 0 TO ($Result.Fields.Count - 1) STEP 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])
'PRINT "Row #: " & iRowIndex
PRINT "Row Called:" & iRowIndex
PRINT "Column Called:" & iColumnIndex
TitleSearchTableView_Data(iRowIndex, iColumnIndex)
NEXT
NEXT
END
PUBLIC SUB TitleSearchTableView_Data(Row AS Integer, Column AS Integer)
$Result.MoveTo(Row)
PRINT Row & "," & Column
TitleSearchTableView.Data.Text =
Str($Result[TitleSearchTableView.Columns[Column].Text])
END
But I get the following in the Console:
Results: 72
Fields: 5
Row Called:0
Column Called:0
0,0
-1,-1
So, I have 72 rows of results, each with 5 fields.
I call the first 0,0 and the _Data Sub seems to receive it. I'm not
sure what the -1,-1 is all about though.
More information about the User
mailing list