Insert into Table with Identity, and then update.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ahijazi
Posts: 47
Joined: Mon 01 Oct 2007 11:13

Insert into Table with Identity, and then update.

Post by ahijazi » Sun 07 Dec 2008 13:08

Dear SDAC Team;

The Case is: Add TMSQuery component to my form and link it to a "TEST" table with "OID" field as identity and "Name" as VarChar , and auto generates the Insert, Update Delete Statements, and set CachedUpdates to True, and connect the MSQuery to DBGrid component.

When try the following procedures a bug is raised:
1- Insert a new record, fill the "Name" value.
2- Call Connection.ApplyUpdate, success with no errors, but "OID" did not get the new value form the database.
3- Edits the row with new value for the "Name" field.
4- Call Connection.ApplyUpdate, failed with "Updates Failed. 0 record found" becuase the "OID" field did not have any value.


I believe this is bug, and if not please told me how to correct this issue???

Best Regards,

Ahmed Hijazi P. Eng.

Code: Select all

CREATE TABLE XY(
	[OID] int IDENTITY(1,1) NOT NULL,
	[Name] varchar(250) NOT NULL
)

ahijazi
Posts: 47
Joined: Mon 01 Oct 2007 11:13

Post by ahijazi » Sun 07 Dec 2008 14:48

Dear SDAC;

I found the solution for what I think is a bug in http://www.devart.com/forums/viewtopic.php?t=11147.


but i have a request if it's possible, why not to give us a design time access for the Insert, Update, Delete Statements Parameters, I think it will be better than write this code every time

Code: Select all

procedure TForm.MSQueryBeforeUpdateExecute( 
  Sender: TCustomMSDataSet; StatementTypes: TStatementTypes; 
  Params: TMSParams); 
begin 
  Params.ParamByName('EMPNO').ParamType := ptInputOutput; 
end;



Best Regard,

Ahmed Hijazi P. Eng.

Dimon
Devart Team
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 09 Dec 2008 10:00

ahijazi wrote:I found the solution for what I think is a bug in http://www.devart.com/forums/viewtopic.php?t=11147.
It is good to see that this problem has been solved.
ahijazi wrote:but i have a request if it's possible, why not to give us a design time access for the Insert, Update, Delete Statements Parameters, I think it will be better than write this code every time
We will investigate the possibility of adding this functionality in the future, but now we have some tasks of higher priority than this.

Post Reply