Implicit conversion from data type sql_variant to uniqueidentifer is not allowed.

If you use guids (uniqueidentifiers) in your database in conjunction with ASP.NET SqlDataSource databinding, chances are you'll eventually run into this error "Implicit conversion from data type sql_variant to uniqueidentifer is not allowed. User the CONVERT function to run this query".

Here is a screenshot of the whole error:


The problem is Visual Studio sucks at picking up the fact that this error will occur EVERY SINGLE TIME and continues to let the error happen.

It's easy to fix though. Find your parameters (selectparameters, insertparameters, etc) for the particular statement you're running (select, update, delete, insert). You should see something like this:



The fix is just to remove the Type = "Object" from the parameter that is linked to the uniqueidentifer column in your table. In this case, the controlparameter "CompanyID"  is linked to the companyid column in my companies table. The resulting code should look like this:


Until Next Time...
«March»
SunMonTueWedThuFriSat
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234