i have a table which has a primary key (UserID) this is of type UniqueIdentifier. im trying to insert a value into this field but i keep getting an error.
i want to get the userID of the current user and insert the into the user_Details table, but i keep getting this error
Conversion failed when converting from a character string to uniqueidentifier
can some one please help me thanks
You have put the parameter inside a string, so it's not identified as a parameter. The effect is that you are trying to convert the string "@UserID" to a GUID instead of using the value in the parameter.
Change the query from
"INSERT INTO dbo.user_Details(UserId)VALUES ('@UserID')"
to:
"INSERT INTO dbo.user_Details(UserId)VALUES (@UserID)"