misnstt
asked on
Error Message When Performing Update in GridView
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
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>
Can you show the <UpdateParameters> section? That's likely where the error is.
ASKER
<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>
<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
</UpdateParameters>
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?
<asp:Parameter Name="UserId" Type="Object" />
<asp:Parameter Name="AnnualLeaveRequestId
It should be Guid type?
ASKER
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
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
<asp:Parameter Name="UserId" Type="System.Guid" />
<asp:Parameter Name="AnnualLeaveRequestId " Type="System.Guid" />
<asp:Parameter Name="AnnualLeaveRequestId
ASKER
Hello that didnt help. When I make those changes I get the error:
The Values permitted For This Attribute Do not Include System.Guid.
The Values permitted For This Attribute Do not Include System.Guid.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks For your help