Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error Message When Performing Update in GridView

Posted on 2008-06-23
8
Medium Priority
?
561 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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