Board index » delphi » "Duplicate index name" w/SQL Server

"Duplicate index name" w/SQL Server

I am getting a "duplicate index name" error when opening a table in SQL
Server using Delphi 3 and BDE 5.01. Originally the problem seemed to affect
only SQL 7.0; now 6.5 is broken as well (?). I have traced down to the where
the problem occurs: in DBTables.pas in the VCL (D3), in
TTable.UpdateIndexDefs, the Cursor does not give the correct number of
indexes (stored in NumIndexes). Instead, it returns the number of fields in
the table. The bogus data it cycles through in the loop results in the
"duplicate index name." I can prevent this if I remove the "dbo." prefix to
the table name (it will report 0 indexes). But this causes a big performance
loss.
Has anyone encountered this problem or have any ideas? Thanks.

Sam

 

Re:"Duplicate index name" w/SQL Server


Re:"Duplicate index name" w/SQL Server


Editing of the data I have constructed under the following scheme.
1. The data are received with the help TStoredProc in a mode CachedUpdates
(+ TUpdateSQL object).
2. On event onAfterPost i'm prepare SQL command (with the help DataSet.
OldValue and DataSet. Value).
3. With the help another of TQuery I send a this command to SQL Server.
4. For updating DataSet I do Close; Open on TStoredProc..

//========================================================
procedure TfrmDivide.quTAfterPost(DataSet: TDataSet);
var
    s:string;
    i :integer;
begin

    s := '';
    with DataSet as TDBDataSet do
    for i := 1 to FieldCount - 1 do
        if (Fields[i].Value <> Fields[i].OldValue) and (Fields[i].FieldKind
= fkData) then
            if length(s) = 0 then
                s := '@'+Fields[i].FieldName+' = '+VarToStr(Fields[i].Value)
            else
                s := s + ', @'+ Fields[i].FieldName+' =
+VarToStr( Fields[i].Value);

    if s = '' then
        Exit;

// Another query
    quX.SQL.Text := 'EXEC cs_DivideLst_Upd @id_doc =
'+DataSet.FieldByName('id_doc').asString+','+s;

    try
        quX.ExecSQL;

        DataSet.Close;
        DataSet.Open;

        except
            on E:EDBEngineError do
            begin
                ShowMessage( E.Message);
                Exit;
            end;
        end;

end;

//=======================================================

My question. At everyone of Close; Open, Delphi creates a "Del??? .MB" file,
size equal to the size TDS (that is 4KB).
After everyone of Close; Open Delphi destroys this file and creates again
(Del1. MB - > Del2. MB and so on)
As the editing dataset occurs in DBGrid, the intensity of such editing is
rather high.
There is a constant work on destruction and creation of such file.
It very much loads workstations, is especial low-power, weak.
How of it to get rid?.
Or it is possible to set a question in another way.
How to organize the program so that to minimize loading on client computer?

( Program client/server. On the client there is no processing, even is not
present calculete fields).

Thank for any answer. Vadim

Re:"Duplicate index name" w/SQL Server


Vadim,

It's not clear to me what you are doing, but I think I can help a
little.

The DEL???.MB file is created because you have CachedUpdates = True.
That file is the local cache that you ask for when you set
CachedUpdates = True. The only way to get rid of it is to set
CachedUpdates = False.

CachedUpdates needs special processing.

First, you fetch the data by saying Open.

Then you make changes to the data. The changes are saved in the
DEL???.MB file.

Then you put the data in the database by saying ApplyUpdates.

If you do only Close/Open and you do not do ApplyUpdates, then you are
not using the value of cached updates and you can set cached updates
to False.

I hope this helps a little.

Phil Cain
--

Re:"Duplicate index name" w/SQL Server


Editing of the data I have constructed under the following scheme.
1. The data are received with the help TStoredProc in a mode CachedUpdates
(+ TUpdateSQL object).
2. On event onAfterPost i'm prepare SQL command (with the help DataSet.
OldValue and DataSet. Value).
3. With the help another of TQuery I send a this command to SQL Server.
4. For updating DataSet I do Close; Open on TStoredProc..

//========================================================
procedure TfrmDivide.quTAfterPost(DataSet: TDataSet);
var
    s:string;
    i :integer;
begin

    s := '';
    with DataSet as TDBDataSet do
    for i := 1 to FieldCount - 1 do
        if (Fields[i].Value <> Fields[i].OldValue) and (Fields[i].FieldKind
= fkData) then
            if length(s) = 0 then
                s := '@'+Fields[i].FieldName+' = '+VarToStr(Fields[i].Value)
            else
                s := s + ', @'+ Fields[i].FieldName+' =
+VarToStr( Fields[i].Value);

    if s = '' then
        Exit;

// Another query
    quX.SQL.Text := 'EXEC cs_DivideLst_Upd @id_doc =
'+DataSet.FieldByName('id_doc').asString+','+s;

    try
        quX.ExecSQL;

        DataSet.Close;
        DataSet.Open;

        except
            on E:EDBEngineError do
            begin
                ShowMessage( E.Message);
                Exit;
            end;
        end;

end;

//=======================================================

My question. At everyone of Close; Open, Delphi creates a "Del??? .MB" file,
size equal to the size TDS (that is 4KB).
After everyone of Close; Open Delphi destroys this file and creates again
(Del1. MB - > Del2. MB and so on)
As the editing dataset occurs in DBGrid, the intensity of such editing is
rather high.
There is a constant work on destruction and creation of such file.
It very much loads workstations, is especial low-power, weak.
How of it to get rid?.
Or it is possible to set a question in another way.
How to organize the program so that to minimize loading on client computer?

( Program client/server. On the client there is no processing, even is not
present calculete fields).

Thank for any answer. Vadim

Re:"Duplicate index name" w/SQL Server


The files you mean are the local copies of the data you request under a
CachedUpdates.
Because you need to edit in the grid you can't set CachedUpdates to false.
No way if you see it in this manner.

A way to work with this is try to separate showing from editing. Show in a
grid, edit in a dialog. (Something like what you do to post this message).
There is always a good excuse, be more accurately with the validation of the
fields, make the user more sensible about the time stay editing a record,
(some drink the coffe while locking a full page), change some colors, ...

October <text...@com2com.ru> escribi en el mensaje de noticias
7g4llg$j0...@forums.borland.com...

Quote

Re:"Duplicate index name" w/SQL Server


Editing of the data I have constructed under the following scheme.
1. The data are received with the help TStoredProc in a mode CachedUpdates
(+ TUpdateSQL object).
2. On event onAfterPost i'm prepare SQL command (with the help DataSet.
OldValue and DataSet. Value).
3. With the help another of TQuery I send a this command to SQL Server.
4. For updating DataSet I do Close; Open on TStoredProc..

//========================================================
procedure TfrmDivide.quTAfterPost(DataSet: TDataSet);
var
    s:string;
    i :integer;
begin

    s := '';
    with DataSet as TDBDataSet do
    for i := 1 to FieldCount - 1 do
        if (Fields[i].Value <> Fields[i].OldValue) and (Fields[i].FieldKind
= fkData) then
            if length(s) = 0 then
                s := '@'+Fields[i].FieldName+' = '+VarToStr(Fields[i].Value)
            else
                s := s + ', @'+ Fields[i].FieldName+' ='
VarToStr( Fields[i].Value);

    if s = '' then
        Exit;

// Another query
    quX.SQL.Text := 'EXEC cs_DivideLst_Upd @id_doc
='+DataSet.FieldByName('id_doc').asString+','+s;

    try
        quX.ExecSQL;

        DataSet.Close;
        DataSet.Open;

        except
            on E:EDBEngineError do
            begin
                ShowMessage( E.Message);
                Exit;
            end;
        end;

end;

//=======================================================

My question. At everyone of Close; Open, Delphi creates a "Del??? .MB" file,
size equal to the size TDS (that is 4KB).
After everyone of Close; Open Delphi destroys this file and creates again
(Del1. MB - > Del2. MB and so on)
As the editing dataset occurs in DBGrid, the intensity of such editing is
rather high.
There is a constant work on destruction and creation of such file.
It very much loads workstations, is especial low-power, weak.
How of it to get rid?.
Or it is possible to set a question in another way.
How to organize the program so that to minimize loading on client computer?

( Program client/server. On the client there is no processing, even is not
present calculete fields).

Thank for any answer. Vadim

Other Threads