GUID Parameters

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
swhaworth
Posts: 2
Joined: Wed 20 Aug 2008 05:32

GUID Parameters

Post by swhaworth » Wed 20 Aug 2008 05:42

SDAC: 4.50.0.36
Codegear C++ Builder 2007

I am using SDAC with a SQLCE 3.5 database and I am trying to fill a table that has a UNIQUEIDENTIFIER field type using parameters. I initialise the parameter by:

Code: Select all

exec->SQL->Text = "INSERT INTO Element (guid) VALUES (:GUID)";
exec->ParamByName("GUID")->DataType = ftGuid;
exec->ParamByName("GUID")->ParamType = ptInput;
exec->ParamByName("GUID")->AsString = Sysutils::GUIDToString(id);
exec->Execute();
This gives the error: 'Requested conversion is not supported. [,,,,,]'.

As far as I can tell this is the way to handle a GUID type, or is there another way?

Thanks for any help

Steve

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

Post by Dimon » Thu 21 Aug 2008 09:37

MS SQL Server CE does not support conversion of field types and values.
The enquiry is the AsString property set DataType to ftString. In order to solve this problem you should use the Value property, like this:

Code: Select all

  exec->ParamByName("GUID")->Value = Sysutils::GUIDToString(id); 

Post Reply