Data conversion failed uniqueidentifier. MS SQL Server Compact
Posted: 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.
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.