Board index » delphi » ado/sqlserver + joins !!?!?

ado/sqlserver + joins !!?!?


2003-10-16 11:23:00 PM
delphi65
Hello
I have a grid with a query and I'd like to update fields manually
everything works fine, but I cannot resync current record after my
beforepost event.
If I call Refresh methode everything works but there are a lot of
records.
I join my query et my event
Can someone give me a solution.
thanks with friendly
:'( :'( :'( :'( :'( :'( :'(
select
v1.idvente,v1.idcontact,r1.residence,l1.numero,p1.promoteur,s1.idsuivicontratassifc,
s1.da{*word*249}voiclient,
s1.datesignatureclient, s1.da{*word*249}voicompagnie, s1.dateretourcompagnie,
s1.da{*word*249}voiclientfinal, s1.datefacturation
from t_vente v1
inner join t_lot l1 on v1.idlot = l1.idlot
inner join t_tranche t1 on l1.idtranche = t1.idtranche
inner join t_residence r1 on t1.idresidence = r1.idresidence
inner join t_promoteur p1 on r1.idpromoteur = p1.idpromoteur
left outer join t_suivicontratassuranceifc s1 on
v1.idcontact=s1.idcontact and v1.idvente=s1.idvente
where v1.dateannulation is null
and v1.dateacte is not null
and v1.datevente>'01/01/2003'
procedure TFSuiviAssuranceIFC.qryDetailBeforePost(DataSet: TDataSet);
var
oQry: TREMQuery;
i: integer;
begin
inherited;
oQry:= TREMQuery.Create(Self);
oQry.Connection := TREMQuery(DataSet).Connection;
oQry.SQL.Clear;
if DataSet.FieldByName('idsuivicontratassifc').IsNull then
begin
oQry.SQL.Add('insert into t_suivicontratassuranceifc (idcontact,
idvente, da{*word*249}voiclient, ');
oQry.SQL.Add(' datesignatureclient, da{*word*249}voicompagnie,
dateretourcompagnie, da{*word*249}voiclientfinal)');
oQry.SQL.Add('values (:idcontact, :idvente, :da{*word*249}voiclient, ');
oQry.SQL.Add(' :datesignatureclient, :da{*word*249}voicompagnie,
:dateretourcompagnie, :da{*word*249}voiclientfinal)');
end
else
begin
oQry.SQL.Add('update t_suivicontratassuranceifc set
idcontact=:idcontact,');
oQry.SQL.Add(' idvente=:idvente,
da{*word*249}voiclient=:da{*word*249}voiclient,');
oQry.SQL.Add(' datesignatureclient=:datesignatureclient,');
oQry.SQL.Add(' da{*word*249}voicompagnie=:da{*word*249}voicompagnie,');
oQry.SQL.Add(' dateretourcompagnie=:dateretourcompagnie,');
oQry.SQL.Add(' da{*word*249}voiclientfinal=:da{*word*249}voiclientfinal');
oQry.SQL.Add('where idsuivicontratassifc=:idsuivicontratassifc');
end;
for i := 0 to oQry.Parameters.Count-1 do
oQry.Parameters[i].Value :=
DataSet.FieldByName(oQry.Parameters[i].Name).Value;
oQry.ExecSQL;
DataSet.Cancel;
Abort;
(*
qryDetail.RecordSet.Properties['Unique Table'].Value :=
't_suivicontratassuranceifc';
qryDetail.Recordset.ReSync(adAffectCurrent, adResyncAllValues);
*)
end;
--
o--O--o
David
 
 

Re:ado/sqlserver + joins !!?!?

If I understand you correctly, what I'd do is update the data via the
querry that is hooked on to the grid. You can do that with either optimistic
or batchoptimistic locking, but by doing it that way your grid will always
reflect the correct data .
 

Re:ado/sqlserver + joins !!?!?

OH .. and by the way .. the proper use of sql with a grid really shouldn't
have "a lot of records". The user should be supplying some hint as to the
type of data they want to see in the grid ... for instance, if looking at a
customer file, you dont want to put +all+ customers in the grid and then
make the user scroll throug 800 records to find "John Smith". They should
supply you with some key, like "smi" and you find all matching customers
"where custname like '%smi%' " and show the results (20 or so hits, which
isn't "a lot of data"). That way you can refresh your query with no worries
about performance.