在VS 2005中,使用VB,页面有一个链接到SqlDataSource的FormView。更改数据并按下更新按钮后,将在FormView中清除已更改的数据,但不会更新数据库表。下面是SqlDataSource代码。任何想法为什么更新不起作用?
<asp:SqlDataSource ID="SqlDataDetails" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ALFSConnectionString %>"
...
...
OldValuesParameterFormatString="original_{0}"
ProviderName="<%$ ConnectionStrings:ALFSConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Resident] WHERE ([Resident_ID] = ?)"
UpdateCommand="UPDATE [Resident] SET [Resident_Company_ID] = ?, ..., [Resident_Diet] = ?, [Resident_Social_Security] = ? WHERE [Resident_ID] = ?" >
<UpdateParameters>
<asp:SessionParameter Name="Resident_ID" SessionField="Resident_ID" Type="String" />
<asp:Parameter Name="Resident_Company_ID" Type="Int32" /> ...
...
...
<asp:Parameter Name="original_Resident_Diet" Type="String" />
<asp:Parameter Name="original_Resident_Social_Security" Type="Int32" />
</UpdateParameters>
...
...
<SelectParameters>
<asp:SessionParameter Name="Resident_ID" SessionField="Resident_ID" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
答案 0 :(得分:0)
看看这里:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.aspx
您的DataSourceMode是什么,和/或您是否正在调用.Update()(如果适用)?