Solved

Error Message When Performing Update in GridView

Posted on 2008-06-23
8
558 Views
Last Modified: 2013-11-26
I am trying to do a Update in a Gridview however am getting the following Error when I press the update button.  Thanks for the assistance.

Error:
Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the convert function to run the query


<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SecurityTutorialsConnectionString %>" 
        
        SelectCommand="SELECT [AnnualLeaveRequestId], [UserId], [PayPeriodId], [name], [SelectedDate1], [SelectedDate2], [SelectedDate3], [SelectedDate4], [SelectedDate5], [SelectedDate6], [SelectedDate7], [Status], [Supervisor], [Date] FROM [RPAnnualLeave] WHERE ([name] = @name)" 
        DeleteCommand="DELETE FROM [RPAnnualLeave] WHERE [AnnualLeaveRequestId] = @AnnualLeaveRequestId" 
        InsertCommand="INSERT INTO [RPAnnualLeave] ([AnnualLeaveRequestId], [UserId], [PayPeriodId], [name], [SelectedDate1], [SelectedDate2], [SelectedDate3], [SelectedDate4], [SelectedDate5], [SelectedDate6], [SelectedDate7], [Status], [Supervisor], [Date]) VALUES (@AnnualLeaveRequestId, @UserId, @PayPeriodId, @name, @SelectedDate1, @SelectedDate2, @SelectedDate3, @SelectedDate4, @SelectedDate5, @SelectedDate6, @SelectedDate7, @Status, @Supervisor, @Date)" 
        UpdateCommand="UPDATE [RPAnnualLeave] SET [UserId] = @UserId, [PayPeriodId] = @PayPeriodId, [name] = @name, [SelectedDate1] = @SelectedDate1, [SelectedDate2] = @SelectedDate2, [SelectedDate3] = @SelectedDate3, [SelectedDate4] = @SelectedDate4, [SelectedDate5] = @SelectedDate5, [SelectedDate6] = @SelectedDate6, [SelectedDate7] = @SelectedDate7, [Status] = @Status, [Supervisor] = @Supervisor, [Date] = @Date WHERE [AnnualLeaveRequestId] = @AnnualLeaveRequestId">
        <SelectParameters>

Open in new window

0
Comment
Question by:misnstt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21847062
Can you show the <UpdateParameters> section?  That's likely where the error is.
0
 

Author Comment

by:misnstt
ID: 21847163
       <UpdateParameters>
            <asp:Parameter Name="UserId" Type="Object" />
            <asp:Parameter Name="PayPeriodId" Type="Int32" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="SelectedDate1" Type="DateTime" />
            <asp:Parameter Name="SelectedDate2" Type="DateTime" />
            <asp:Parameter Name="SelectedDate3" Type="DateTime" />
            <asp:Parameter Name="SelectedDate4" Type="DateTime" />
            <asp:Parameter Name="SelectedDate5" Type="DateTime" />
            <asp:Parameter Name="SelectedDate6" Type="DateTime" />
            <asp:Parameter Name="SelectedDate7" Type="DateTime" />
            <asp:Parameter Name="Status" Type="String" />
            <asp:Parameter Name="Supervisor" Type="String" />
            <asp:Parameter Name="Date" Type="DateTime" />
            <asp:Parameter Name="AnnualLeaveRequestId" Type="Object" />
        </UpdateParameters>
   
0
 
LVL 2

Expert Comment

by:Alexey_Varlamov
ID: 21847229
The possible problems are in the following strings:

<asp:Parameter Name="UserId" Type="Object" />
<asp:Parameter Name="AnnualLeaveRequestId" Type="Object" />

It should be Guid type?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:misnstt
ID: 21847486
Good Morning,
Thanks for your response.  I am very much a beginner.  I am not sure what you mean by Guid Type or what I need to change.
Thanks
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21847587
<asp:Parameter Name="UserId" Type="System.Guid" />
<asp:Parameter Name="AnnualLeaveRequestId" Type="System.Guid" />
0
 

Author Comment

by:misnstt
ID: 21847792
Hello that didnt help.  When I make those changes I get the error:
The Values permitted For This Attribute Do not Include System.Guid.

0
 
LVL 2

Accepted Solution

by:
Alexey_Varlamov earned 500 total points
ID: 21847945
Ok, try to remove the  Type="Object"  statement and let ASP.NET to detect correct type itself.

Another workaround required little coding: http://weblogs.asp.net/dwahlin/archive/2006/10/10/GUIDs-and-DataSource-Controls.aspx

0
 

Author Closing Comment

by:misnstt
ID: 31469766
Thanks For your help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question