Board index » delphi » DBEdit And EDIT Using TQuery going against SQL SERVER 6.5

DBEdit And EDIT Using TQuery going against SQL SERVER 6.5

Hi

    The following I need to ask when using a TQUERY can I use DBEDIT and how
do I link the DBEDiT to the result set coming back from the TQUERY below
against SQL SERVER. Tha following is my code to do what the locate function
is suppose to do. I tried the filter but that was to slow so this is the
next soloution I need to benchmark. I their a way to use the DBEDIT if their
is please explain in detail maybe show me example of how to do it - If I
need to change it to a EDIT control because the TQUERY CAN NOT BE USED then
I need to know that but if it can I would like a example of both the DBEDIT
and then the EDIT - do one make a difference from the other. Where in the
code do I or would I attach the result set coming back from the TQUERY it
needs to be some where inside the While NOT(EOF) do loop.

Note: I Removed code so that the code is more readable below

The First to put the record pointer at the beginging of the file can that be
used with a TQUERY or not if so how can it be used please give a example -
If it can not what is needed if anything or are we put at the begining of
the file anyhow - and each time the RollIssueLinks function gets called
should we be put at the begin of the file before doing the SeekQuery
function.

Function SeekQuery(MyTable: String; MyRecordPtr: Integer): Boolean;
Begin
     SeekQuery := False;

     if MyTable = 'MODIssues' Then
        Begin
            With DataModule2.Query2 Do Begin
                DisableControls;
              Try
                Close;
                SQL.Clear;
                SQL.Add('Select From ModIssues');
//              SQL.Add('Where Case_Numb = '+'"'+s+'"');   // This Works If
String

                SQL.Add('Where Case_Numb = '+ IntToStr(MyRecordPtr));   //
This Works If String

                Open;

                SeekQuery := True;
              Finally
                EnableControls;
              End; // Try

            End;// With

        End;

End;

Function RollIssueLinks(CaseNumber: String; Var MessageTripFlag: Boolean):
Boolean;
Begin

 With DataModule2.Query2 do Begin

     First;

     // We need to find a way to speed this up with a seek
     // so we can seek to the last record before and pick up the record
count
     // from that point other was the merging of the ModIssue will just take
     // to long

     // Seek Function - TQUERY
     RetFound := SeekQuery('MODIssues', TempCaseNo);                  //
GOOD

    // RetFound := Locate('Case_Numb',TempCaseNo,[]);                    //
BAD - NOT USED

     While NOT(EOF) do
       begin

           // CODE GOES HERE   -   DBEDIT    OR    EDIT would go some where
here

           Application.ProcessMessages;

           if NOT(KeepGoing) Then
              Begin
                  Last;   {Forces EOF to Become True}

              End;

         Next;

       End;

       PrevOldCaseNumber :=  OldCaseNumber;

   End;// With

End;

 

Re:DBEdit And EDIT Using TQuery going against SQL SERVER 6.5


Quote
Frank H. Shaw wrote in message <8u7nrp$t...@bornews.inprise.com>...

>    The following I need to ask when using a TQUERY can I use DBEDIT and
how
>do I link the DBEDiT to the result set coming back from the TQUERY below
>against SQL SERVER.

TDBEdits (and all data-aware controls) link to TQuerys *exactly* the same as
they link to TTables. Connect a TDatasource to the TQuery, connect the
DBEdit to the TDatasource and set the field name in the TDBEdit..This can be
done at design-time or in code, but you would not and need not do it inside
the loop.

The bigger question is why do you *want* a TDBEdit connected to the ModIssue
table while processing this loop? Did you do this with the TTable? That
would be one reason why it is so slow! If you want performance in a loop
that processes many records then you do not want data-aware controls
connected. I note you are calling DisableControls / EnableControls, but you
are only calling this around the execution of the query. This doesn't really
help you much, it needs to surround the entire processing loop.

If you are connecting the TDBEdit only so you have something to watch while
the loop processes, then try using a TAnimate or a label you update manually
once every 100 or 500 records.
--
Wayne Niddery (WinWright Inc.)
RADBooks - http://members.home.net/wniddery/
I love deadlines. I like the whooshing sound they make as they pass by -
Douglas Adams

Re:DBEdit And EDIT Using TQuery going against SQL SERVER 6.5


I agree and I'll add if your needing to process a lot of records, it's
better handled on the server using a stored procedure.  Need help writing
stored procedures, check out SQL Navigator from Quest software
(http://www.quest.com)  It's IDE is almost identical to Delphi's (BTW, SQL
Nav is written in Delphi) with features like code insight, code templates
and the best feature (IMO) a stored procedure de{*word*81}.

Good luck,
krf

Re:DBEdit And EDIT Using TQuery going against SQL SERVER 6.5


Ok - The use of First and the use of Last when using a TQUERY how does the
BDE handle if it encounters a Query2.First. In my code the First happens
before the SeekQuery Function Gets called. So does the First used in this
case cause all the records to come down from the server? Do we need to set
the record pointer at the begining of the file before doing the Function I
created SeekQuery - Look at orginal posting for the code.  Please Explain
things in detail about what is happening above.

How do I use the DisableControls and EnableControls because inside the loop
I need to update the DBEDIT control so It will show to the user the records
that the actual processing is being done on. This is important for the user
to see this happening at least durn this stage of the conversion process. I
understand this will slow things done a bit. I need to bench mark the use of
the DBEDIT VS EDIT control and mybee some other controls we need to check
out also. THANKS

Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
news:3a078a85_1@dnews...

Quote
> Frank H. Shaw wrote in message <8u7nrp$t...@bornews.inprise.com>...

> >    The following I need to ask when using a TQUERY can I use DBEDIT and
> how
> >do I link the DBEDiT to the result set coming back from the TQUERY below
> >against SQL SERVER.

> TDBEdits (and all data-aware controls) link to TQuerys *exactly* the same
as
> they link to TTables. Connect a TDatasource to the TQuery, connect the
> DBEdit to the TDatasource and set the field name in the TDBEdit..This can
be
> done at design-time or in code, but you would not and need not do it
inside
> the loop.

> The bigger question is why do you *want* a TDBEdit connected to the
ModIssue
> table while processing this loop? Did you do this with the TTable? That
> would be one reason why it is so slow! If you want performance in a loop
> that processes many records then you do not want data-aware controls
> connected. I note you are calling DisableControls / EnableControls, but
you
> are only calling this around the execution of the query. This doesn't
really
> help you much, it needs to surround the entire processing loop.

> If you are connecting the TDBEdit only so you have something to watch
while
> the loop processes, then try using a TAnimate or a label you update
manually
> once every 100 or 500 records.

> --
> Wayne Niddery (WinWright Inc.)
> RADBooks - http://members.home.net/wniddery/
> I love deadlines. I like the whooshing sound they make as they pass by -
> Douglas Adams

Re:DBEdit And EDIT Using TQuery going against SQL SERVER 6.5


For #1, http://community.borland.com/article/0,1410,15227,00.html

For #2: Is the end-user going to modify the data?  Does it have to be a
dbEdit/edit box?  Can you use a label?

krf

"If your writing a lot of code to do something, your probably doing it
wrong."
-- Marco Cantu

Re:DBEdit And EDIT Using TQuery going against SQL SERVER 6.5


For #1, http://community.borland.com/article/0,1410,15227,00.html

For #2: Is the end-user going to modify the data?  Does it have to be a
dbEdit/edit box?  Can you use a label?

krf

"If your writing a lot of code to do something, your probably doing it
wrong."
-- Marco Cantu

Other Threads