Click here to Skip to main content
15,891,136 members
Articles / Web Development / ASP.NET
Tip/Trick

Uniqueidentifier Field Problem

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
2 Oct 2010CPOL 9.1K   2  
One of the problems i faced, when i try to update a record with a "ueidentifier" field. using SqlDataSource.. it was giving me the following error:

CSS
Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement IConvertible.



Solution

The crux of the problem, it appears, is that the <asp:Parameter> value for the uniqueidentifier field is, by default, set to Type="Object". To fix this, simply remove the Type property altogether. That is, change the SqlDataSource parameter setting from something like:



XML
<asp:SqlDataSource ...>
  <InsertParameters>
    <asp:Parameter Name="UserId" Type="Object" />
    ...
  </InsertParameters>
</asp:SqlDataSource>

to:

<asp:SqlDataSource ...>
  <InsertParameters>
    <asp:Parameter Name="UserId"  />
    ...
  </InsertParameters>
</asp:SqlDataSource>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Gulf air - Bahrain
Bahrain Bahrain
Current Position is : Sr. Information System Analyst

Leading a Team of Developers for developing ecommerce websites and systems integration using several integration methods such as XML.

Manage ISP infrastructure, web servers, database servers, application servers, email servers and networks. Design the architecture of complex web applications; build web applications in JAVA, asp, asp.Net; manage web sites including networking and database; experienced in MS Sql Server and Oracle;

stay current with emerging trends and technological advances in the industry.

MCTS,MCAD VB.NET, ASP.NET and XML Services,BTEC National Diploma in Computer Studies.

Comments and Discussions

 
-- There are no messages in this forum --