views:

209

answers:

1

hey all,

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

+1  A: 

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)"
Guffa
OMG ... i was tying all sorts of things ... thanks a lot dude !!
c11ada
@c11ada: It's always harder to spot an error in code that you have written yourself. You tend to read it as what you were thinking when you wrote it instead of reading what's actually there. :)
Guffa