Newbie help needed - SQL query + results
Moderators: gto, cipto_kh, EgonHugeist
-
- Fresh Boarder
- Posts: 22
- Joined: 26.08.2008, 12:36
Newbie help needed - SQL query + results
As newbie, I already got as far as setting up a connection,
and by means of ZComponent being able to read the databases,
and from a database being able to read all the tables.
Next step woul dbe to perform queries and display results...
Unfortunately could not find how-to's ....
does anyone have an example?
and by means of ZComponent being able to read the databases,
and from a database being able to read all the tables.
Next step woul dbe to perform queries and display results...
Unfortunately could not find how-to's ....
does anyone have an example?
you can do many things when connected, let's take a simple example:
- Add a TZQuery component into the form and name it (example MyQuery). Link it to the ZConnection component via property Connection.
- Add a TDataSource and link it (property Dataset) to MySQL.
- Add a TDBGrid an connect it to the datasource.
- Enter a SQL sentence into the MyQuery.SQL.Text, ecample "Select * From, TABLENAME.
- In the code execute this MyQuery.Active := true; or MyQuery.Open; In the grid should appear the requested records.
You can do the same in design time to see the result ASAP...
Please note that this is just basic functioning. Upon starting the application you shoud connect and open tables by code - with exception handling.
- Add a TZQuery component into the form and name it (example MyQuery). Link it to the ZConnection component via property Connection.
- Add a TDataSource and link it (property Dataset) to MySQL.
- Add a TDBGrid an connect it to the datasource.
- Enter a SQL sentence into the MyQuery.SQL.Text, ecample "Select * From, TABLENAME.
- In the code execute this MyQuery.Active := true; or MyQuery.Open; In the grid should appear the requested records.
You can do the same in design time to see the result ASAP...
Please note that this is just basic functioning. Upon starting the application you shoud connect and open tables by code - with exception handling.
-
- Fresh Boarder
- Posts: 22
- Joined: 26.08.2008, 12:36
-
- Fresh Boarder
- Posts: 22
- Joined: 26.08.2008, 12:36
here's what I done so far
add Zconnection
-set Protocol=mssql
-set hostname
-set username
-set password
-set database
add TDataSource
add ZQuery
-set conenction to ZConnection1
-set datasource to TDataSource
-set SQL (query)
add DBGrid
-set datasource to TDataSource
ZConnection.Connect
Zquery1.Open
nada...
found a code somwhere else
memo1.Lines.Add(ZQuery1.FieldByName(ZQuery1.Fields[1].FieldName).asString);
this shows the query is getting a result,
jsut seem to be short the link between ZQuery and TDatasource ???
add Zconnection
-set Protocol=mssql
-set hostname
-set username
-set password
-set database
add TDataSource
add ZQuery
-set conenction to ZConnection1
-set datasource to TDataSource
-set SQL (query)
add DBGrid
-set datasource to TDataSource
ZConnection.Connect
Zquery1.Open
nada...
found a code somwhere else
memo1.Lines.Add(ZQuery1.FieldByName(ZQuery1.Fields[1].FieldName).asString);
this shows the query is getting a result,
jsut seem to be short the link between ZQuery and TDatasource ???
-
- Fresh Boarder
- Posts: 22
- Joined: 26.08.2008, 12:36