Page 1 of 1

GUID Parameters

Posted: Wed 20 Aug 2008 05:42
by swhaworth
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

Posted: Thu 21 Aug 2008 09:37
by Dimon
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);