Last post May 16, 2018 03:19 PM by Saavik
Apr 23, 2018 03:54 PM|Saavik|LINK
I have an SqlDataSource linked to a FomView.
Some of the values are supplied by bound controls on the FormView, others are supplied in code-behind.
The order of the parameters to the UPDATE command in SqlDataSource in .aspx is correct.
All the values are correct. Here is the problem:
When I look at the order of the parameters to the Command in SqlDataSource_Updating, the last two have changed order.
I am baffled. Why has the order of parameters changed? Is this the reason the command fails?
Help most appreciated.
Apr 24, 2018 10:07 AM|Eric Du|LINK
According to your description, maybe your command is fail when you execute this command, could you tell us your exception message or provide the related code?
Apr 24, 2018 06:54 PM|Saavik|LINK
I know the command fails because I could see (in debug) the problem I described, where the parameters order has changes - this would cause wrong values to be passed to the command. Since the UPDATE happens "inside" an SqlDataSource, there is no error message.
I am truly baffled - I have used SqlDataSource for years, and have never seen this situation.
Apr 25, 2018 09:54 AM|Eric Du|LINK
According to your description and code, could you post related code for us to check?
May 16, 2018 03:19 PM|Saavik|LINK
Here is the SqlDataSource whose Update operation fails.
<asp:SqlDataSource ID="MenuDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnection %>"
ProviderName="<%$ ConnectionStrings:MyConnection.ProviderName %>"
UpdateCommand="UPDATE Menu SET MenuName = ?, MenuImage = ?, MenuSelectedImage = ?, NextLevelMenuId = ?, FriendlyUrlId = ?, OptionIsActive = ?, DoNotUseOptionUrl = ?, ShowOnSideMenu = ?, ShowOnHomePage = ? WHERE (LangCodeLCase = ?) AND (ServerHost = ?) AND (MenuId
= ?) AND (OptionNumber = ?)">
<asp:Parameter Name="MenuName" />
<asp:Parameter Name="MenuImage" />
<asp:Parameter Name="MenuSelectedImage" />
<asp:Parameter Name="NextLevelMenuId" />
<asp:Parameter Name="FriendlyUrlId" />
<asp:Parameter Name="OptionIsActive" />
<asp:Parameter Name="DoNotUseOptionUrl" />
<asp:Parameter Name="ShowOnSideMenu" />
<asp:Parameter Name="ShowOnHomePage" />
<asp:ControlParameter ControlID="SelectLanguageDdl" Name="LangCodeLCase" PropertyName="SelectedValue" />
<asp:SessionParameter Name="ServerHost" SessionField="ServerHost" />
<asp:ControlParameter ControlID="SelectMenuDdl" Name="MenuId" PropertyName="SelectedValue" />
<asp:Parameter Name="OptionNumber" />
At runtime, the values for ControlParameter LangCodeLCase and MenuId get interchanged. Obviously, the update operation fails.