Search code examples
asp.netsqlguidsqldatasource

how to pass a GUID to a select query of SqlDataSource


I have an SqlDataSource with following command:

SELECT * FROM [vw_aspnet_MembershipUsers] WHERE ([UserId] = @UserId)

When I pass simple GUID like "3bd08871-d5d6-4f38-8c8a-29fd6077a719" as a UserId, then nothing gets selected. So what is the correct format for passing the GUID value?


Solution

  • Had to change the parameter's type from Object to String:

      <asp:QueryStringParameter Name="UserID" QueryStringField="UserID" Type="String" />