关于sqldatasource的问题
<asp:SqlDataSource ID= "SqlDataSource2 " runat= "server " DataSourceMode=DataSet
ConnectionString= " <%$ ConnectionStrings:drmConnectionString2 %> "
SelectCommand= "SELECT [ProgramID], [IsAvailable], [ProgramTitle], [ProgramRemark], [ProgramContent], [MovieCount], [WholesalePoint], [PromotionPoint], [ContentProvider] FROM [ProgramData] "
DeleteCommand= "DELETE FROM [ProgramData] WHERE [ProgramID] =@ProgramID "
InsertCommand= "INSERT INTO ProgramData(ProgramTitle, IsAvailable, MovieCount, WholesalePoint, PromotionPoint, ContentProvider,ProgramRemark,ProgramContent) VALUES (@ProgramTitle, @IsAvailable,@MovieCount, @WholesalePoint, @PromotionPoint, @ContentProvider,@ProgramRemark,@ProgramContent) "
UpdateCommand= "UPDATE [ProgramData] SET [ProgramTitle] = @ProgramTitle, [IsAvailable] = @IsAvailable, [MovieCount] = @MovieCount, [WholesalePoint] = @WholesalePoint, [PromotionPoint] = @PromotionPoint, [ContentProvider] = @ContentProvider, [ProgramRemark] = @ProgramRemark, [ProgramContent] = @ProgramContent WHERE [ProgramID] = @ProgramID "
ConflictDetection= "CompareAllValues " >
<DeleteParameters>
<asp:Parameter Name= "ProgramID " Type=Int32 />
</DeleteParameters>
<InsertParameters>
<asp:FormParameter Name= "ProgramTitle " FormField= "ProgramTitle " />
<asp:FormParameter Name= "IsAvailable " FormField= "IsAvailable " />
<asp:FormParameter Name= "MovieCount " FormField= "MovieCount " />
<asp:FormParameter Name= "WholesalePoint " FormField= "WholesalePoint " />
<asp:FormParameter Name= "PromotionPoint " FormField= "PromotionPoint " />
<asp:FormParameter Name= "ContentProvider " FormField= "ContentProvider " />
<asp:FormParameter Name= "ProgramRemark " FormField= "ProgramRemark " />
<asp:FormParameter Name= "ProgramContent " FormField= "ProgramContent " />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name= "ProgramTitle " Type=String/>
<asp:Parameter Name= "IsAvailable " Type=Int32/>
<asp:Parameter Name= "MovieCount " Type=Int32/>
<asp:Parameter Name= "WholesalePoint " Type=Decimal/>
<asp:Parameter Name= "PromotionPoint " Type=Decimal />
<asp:Parameter Name= "ContentProvider " Type=String/>
<asp:Parameter Name= "ProgramRemark " Type=String/>
<asp:Parameter Name= "ProgramContent " Type=string/>
</UpdateParameters>
</asp:SqlDataSource>
我在执行的时候 插入和删除都没有问题 更新的时候不起作用 也没有包错
请高手指点一下 急急急急急急急急急急急急急急急!!!!!!!!1
------解决方案--------------------
启动SQL性能分析器SQL Server Profiler,跟踪一下更新时发送的SQL语句自然就明白了
另外,更新参数列表 <UpdateParameters> 里好像少了关键字段参数 <asp:Parameter Name= "ProgramID " Type=Int32 /> ,加上试试
[解决办法]
SqlDataSource onupdating 输出@ProgramID的值看看吧
[解决办法]
ConflictDetection= "CompareAllValues " 去掉试试,这个启用了OldValue字典,而你又没制定OldValueFormatString,所以把NewValue 覆盖了