Reputation: 7676
Please note that presently I am attempting to execute the following INSERT command via C# ADO.NET, but am receiving the above error:
INSERT INTO tblStampAnnotation ([StampAnnotationID],[Title],[Subject],[Content],[Author],[Date],[LinkedDocumentsID],[PageNumber],[Colour]) VALUES('{6b15a625-b967-4d3b-9ee3-34f64633f469}','test title','test subject','test content','test author',GETDATE(),'{475f30a1-142f-4fd5-b783-598d838559de}',1,Null)
Found a small program to check if GUID is correct here: http://www.devx.com/vb2themax/Tip/18293
When I run the program, it indicates that both the {6b15a625-b967-4d3b-9ee3-34f64633f469} and {475f30a1-142f-4fd5-b783-598d838559de} are GUIDs. Does anyone have any suggestions to determine why I am receiving this error? TIA.
UPDATE:
Thank you for the suggestion, bobs; however, when I use the following command I still get the same error:
INSERT INTO tblStampAnnotation ([StampAnnotationID],[Title],[Subject],[Content],[Author],[Date],[LinkedDocumentsID],[PageNumber],[Colour]) VALUES('6b15a625-b967-4d3b-9ee3-34f64633f469','test title','test subject','test content','test author',GETDATE(),'475f30a1-142f-4fd5-b783-598d838559de',1,Null)
UPDATE 2: Please note that I am using SQL Server 2008.
UPDATE 3: This is getting strange. I still receive the same error when I use NEWID():
INSERT INTO tblStampAnnotation ([StampAnnotationID],[Title],[Subject],[Content],[Author],[Date],[LinkedDocumentsID],[PageNumber],[Colour]) VALUES(NEWID(),'test title','test subject','test content','test author',GETDATE(),NEWID(),1,Null)
Upvotes: 2
Views: 8179
Reputation: 22184
You should remove the braces {} from the GUID value.
'6b15a625-b967-4d3b-9ee3-34f64633f469'
Upvotes: 5
Reputation: 7676
It turns out that I had copied this table over from another database using the right-click on database -> Tasks... -> Import Data and then I got the uniqueidentifier error. To solve the problem, I deleted the table, and re-created it using the "New Table..." designer, and after I tried the same first INSERT command it worked fine, so something weird happened when I copied it over using import. Thank you everyone for your suggestions.
Upvotes: 3