Am reciti mail tau si am mai gasit o observatie:
Selectul pe care l-ai introdus nu iti intoarce un singur rezultat ci un
subset de rezultate, poate avea o touple sau mai multe. Pentru a rezolva acest
lucrumai poti face urmatiorul lucru:
Creaza un cursor in mysql care sa returneze toate inregistrarile din gestiuni
pentru locatia introdusa ca parametru :
create view aaaa select * from gestiuni a where a.id_locatie = :numar de
locatie dorit
definesti un tsqldataset pentru acest view
si cind citesti din forma un id de locatie il transmiti ca parametru
view-ului pe care in apelezi cu o instructiune de genul select * from aaaa si
iti returneaza tot setul chiar daca contine ouna sau mai multe rezultate.
selectul folosit de tine iti intoarce o tabelea in care ai atasate cimpurile
din locatii si gestiunile aferente in urmatoatarea forma:
locatia 1 gestiuea 1
locatia 1 gestiunea 3
locatia 1 gestiune 10
locatia 2 gestiunea 2
locatia 2 gestiunea 4
etc si nu cred ca asta este rezultatul pe care il doresti
daca ai putina rabdare pe sfirsitul asta saptamina, dupa ce imi instalez
mysql-ul (sa imi comunici ce varianta ai pentru compatibilitate) o sa iti fac
un demonstrativ mic la problema
ta si iti trimit si sursele aferente sa vezi cum merge, numai daca vrei.
Cu stima si respect pentru incepatori
Adrian POPA
PS. scuza-mi eventualele greseli de ortografie, nu imi corectez textul dupa
ce il tastez
bogdan_pricop <[EMAIL PROTECTED]> wrote:
Hello,
First of all You must know that I'm kind of new to Delphi.
Background:
I need to write an app that reads and write data from/in MSSQL, and do
this with stored procedures.
My problem: I have made a form on witch I put:
SQLConnection1: TSQLConnection;
//Societate= Company name
//StorePorc: GEN_ZoomSocietati ; no parameter required, return
data in dsSoc
dsSocietate: TDataSource;
sdsSocietate: TSQLDataSet;
cblSocietate: TDBComboBox;
//Locatie = Location
//StorePorc: GEN_ZoomDimensiuni ; no parameter required, return
data in dsLoc
dsLocatie: TDataSource;
sdsLocatie: TSQLDataSet;
cblLocatie: TDBComboBox;
// Gest =
//StorePorc: THG_GetGestiune ; parameter: idlocatie
// return a list of things that are linked by Location by the
idlocation field
dsGest: TDataSource;
sdsGest: TSQLDataSet;
cblGest: TDBComboBox;
I can execute the StoredProc that are without any params, and get the
date, and populate the combos like this:
dsSocietate.DataSet.First;
while not dsSocietate.DataSet.Eof do
begin
ss:= ToString(dsSocietate.DataSet.FieldValues['societate']);
cblSocietate.Items.Add(ss);
dsSocietate.DataSet.Next;
end;
dsLocatie.DataSet.First;
while not dsLocatie.DataSet.Eof do
begin
ss:= ToString(dsLocatie.DataSet.FieldValues['denumire']);
cblLocatie.Items.Add(ss);
dsLocatie.DataSet.Next;
end;
Here is my THG_GetGestiune StoreProc
CREATE PROCEDURE THG_GetGestiune
@idlocatie INT = NULL
AS
SET NOCOUNT ON
SELECT g.codgestiune, g.denumire, g.descarcare, g.codpersoana,
g.codgestionar
FROM thg_locatii_gestiuni lg
INNER JOIN gestiuni g ON lg.codgestiune = g.codgestiune
WHERE lg.idlocatie = @idlocatie
SET NOCOUNT OFF
THE QUESTION:
How can I pass a parameter to this stored procedure?
I have tried with:
sdsGest.CommandType := ctStoredProc;
sdsGest.CommandText := 'THG_GetGestiune';
sdsGest.ParamByName('@idlocatie').Value := 9;
sdsGest.ExecSQL;
and aplication crash with message "List out of bounds(0)"
Please help,
Tanks in advance
---------------------------------
Don't be flakey. Get Yahoo! Mail for Mobile and
always stay connected to friends.
[Non-text portions of this message have been removed]