All writing

ASP .NET, GridViews, SqlDataSource, and Guid Parameters

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.

Sheet
A-3 · Detail
Drawn
Utah
Scale
1:1
Rev
2026