BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Updating GUID-field for ADO.NET in Delphi 2005

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
R. Hoek
Guest





PostPosted: Mon May 07, 2007 6:53 pm    Post subject: Updating GUID-field for ADO.NET in Delphi 2005 Reply with quote



For some reason, when I'm trying to update a GUID field, an error occures.

I've create a very simple application using a MSDE database, with two
uniqueidentifier fields. I'm using TADOConnection and a TADOQuery.

This is what I do....

ADOQuery1.SQL.Text := 'Select * from ADMINS order by [ID]';
ADOQuery1.Open;
ADOQuery1.Edit;
ADOQuery1.FieldByName('SID_LOCK').Value := Guid.NewGuid.ToString();
ADOQuery1.Post; <---- Error!!!

The error is: Bij een bewerking die uit meerdere stappen bestaat, is een
fout opgetreden. Controleer alle statuswaarden.

Translated (as good as it could): During an operation with multiple steps,
an error ocurred. Check all statusvalues.



I'm running Windows XP (NL) with Delphi 2005 SP3

--
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.
Back to top
R. Hoek
Guest





PostPosted: Mon May 07, 2007 6:59 pm    Post subject: Re: Updating GUID-field for ADO.NET in Delphi 2005 Reply with quote



A addition to this question:

- Is the GUID-type field (unniqueindentifier) supported on ADO?

--
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.
Back to top
R. Hoek
Guest





PostPosted: Mon May 07, 2007 7:04 pm    Post subject: Re: Updating GUID-field for ADO.NET in Delphi 2005 - This DO Reply with quote



I'm using the same code for Delphi 6 and then it works perfectly!

--
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.
Back to top
Brian Bushay TeamB
Guest





PostPosted: Tue May 08, 2007 7:17 am    Post subject: Re: Updating GUID-field for ADO.NET in Delphi 2005 Reply with quote

Quote:
A addition to this question:

- Is the GUID-type field (unniqueindentifier) supported on ADO?

Yes. Type AdGuid

--
Brian Bushay (TeamB)
Bbushay (AT) NMPLS (DOT) com
Back to top
R. Hoek
Guest





PostPosted: Tue May 08, 2007 2:19 pm    Post subject: Re: Updating GUID-field for ADO.NET in Delphi 2005 - found t Reply with quote

I Found the error to be an problem with using the Guid.ToString() method of
the .NET framework in conjuction with the way the TGUIDField is used by
Borland.

In the Unit "DB" at line 7387 (implementation of the TGuidField.SetAsGuid)

procedure TGuidField.SetAsGuid(const Value: TGUID);
begin
SetAsString(GuidToString(Value));
end;


This uses the function "GUIDToString" in Unit "SysUtils" at line 6666

function GUIDToString(const GUID: Borland.Delphi.System.TGUID): string;
begin
Result := GUID.ToString;
end;

As you can see, this routine uses the GUID.ToString method. The problem wit
this, is that the function returns the GUID without the {} around it, thus
resuting in aan error when posting this data to the ADORecordSet....

This will propebly affect all TDataset descendents which use the TGuidField
and setting it using "AsGUID"....
When u use this kind of field and use the AsString property by setting the
GUId with the correct syntax
AsString := '{' + Guid.ToString() + '}'
No problem will occure....

--
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.


"R. Hoek" <*nospam*hoek (AT) componentagro (DOT) nl*nospam*> schreef in bericht
news:463f2f43$1 (AT) newsgroups (DOT) borland.com...
Quote:
For some reason, when I'm trying to update a GUID field, an error occures.

I've create a very simple application using a MSDE database, with two
uniqueidentifier fields. I'm using TADOConnection and a TADOQuery.

This is what I do....

ADOQuery1.SQL.Text := 'Select * from ADMINS order by [ID]';
ADOQuery1.Open;
ADOQuery1.Edit;
ADOQuery1.FieldByName('SID_LOCK').Value := Guid.NewGuid.ToString();
ADOQuery1.Post; <---- Error!!!

The error is: Bij een bewerking die uit meerdere stappen bestaat, is een
fout opgetreden. Controleer alle statuswaarden.

Translated (as good as it could): During an operation with multiple steps,
an error ocurred. Check all statusvalues.



I'm running Windows XP (NL) with Delphi 2005 SP3

--
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.