Data conversion failed uniqueidentifier. MS SQL Server Compact

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
jyarnot
Posts: 6
Joined: Tue 27 May 2008 15:48

Data conversion failed uniqueidentifier. MS SQL Server Compact

Post by jyarnot » Tue 27 May 2008 16:10

I am attempting to store a string representation of a GUID in a field of type uniqueidentifier using the MS SQL Server compact version of the driver. I am storing it in a string variable and then attempting to put it into the database using AsString. When I apply updates, I get the error. This same code works against MS SQL Server Express using the driver included with Code Gear studio 2007. The specific error I get is: "Data conversion failed. [OLE DB status value (if known): 2, 0, 0,,,]"
Code snippet below:

cdsUsers is a TClientDataSet
UserID and UserName are strings

cdsUsers.ReadOnly := False;
cdsUsers.Open;
cdsUsers.Append;
UserID := GetNextRecordID; //Gets a GUID as a string
cdsUsers.FieldByName('RecordID').AsString := UserID; //field type is uniqueidentifier
cdsUsers.FieldByName('UserName').AsString := UserName; //fieldtype is nvarchar(20)
cdsUsers.Post;
cdsUsers.ApplyUpdates(0);

The error comes up when the last line above is executed. Any suggestions? Is this functionality not in place yet? Thanks.

Also, I can generate a GUID and insert it into my table using MS SQL Server Management Studio Express without problem, so I'm fairly confident the db is setup correctly.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 28 May 2008 11:43

I could not reproduce the problem.
Please send me a complete small sample at dbxsda*crlab*com to demonstrate it, including the database file.

Also supply me the following information:
- the exact version of DbxSda;
- the exact version of your IDE.

Post Reply