Another thing I ran into today. I actually ran into it awhile back but since I ran into it again today I’d thought I’d post on it to help anyone who happens to find it.
Problem
You have a GridView and a SqlDataSource that takes 1 or more Guids as a Parameter. You use the built in DataSource configuration and it doesn’t give any errors. However, when you actually run it and pass the Guid, you get this error:
“Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.”
Solution
Inside your source look at your DataSource. The parameter tag will look something like this:
<asp:QueryStringParameter Name=”Customer_IID” QueryStringField=”iid” Type=”Object” />
Change the Type to Empty like this:
<asp:QueryStringParameter Name=”Customer_IID” QueryStringField=”iid” Type=”Empty” />
I have no clue why Visual Studio 2005 thinks a Guid should be an Object and not an Empty, but this will fix your problems.
awsom! Thank you
LikeLike
This did the trick. I’ve been working on this all night.
LikeLike
Thanks for this. Spot on.
This is still a bug in VS2010 (using Microsoft Visual Web Developer 2010 Express).
LikeLike
ASP .NET, GridViews, SqlDataSource, and Guid Parameters | Justin Carmony I was recommended this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my trouble. You are wonderful! Thanks! your article about ASP .NET, GridViews, SqlDataSource, and Guid Parameters | Justin CarmonyBest Regards Agata
LikeLike