zoukankan      html  css  js  c++  java
  • 关于微软有自增列父子表更新程序的问题

    有一些不明白它的意思.请高手详细说明一下原由.谢谢!
    来源网址:http://support.microsoft.com/?scid=kb%3Bzh-cn%3B320301&x=11&y=15


            
    protected static void OnDetailsRowUpdated(object sender, SqlRowUpdatedEventArgs args)
            {
                
    if(args.StatementType == StatementType.Insert )
                {
                    
    // Do not allow the AcceptChanges to occur on this row.
                    args.Status = UpdateStatus.SkipCurrentRow;//这里为什么要用UpdateStatus.SkipCurrentRow

                    
    // Get the current, actual primary key value so that you can plug it back
                    
    // in after you get the correct original value that was generated for the child row.
                    int currentkey = (int)args.Row["OrderID"];
                    
    // This is where you get a correct original value key that is stored to the child row. 
                    
    // You pull the original, pseudo key value from the parent, plug it in as the child row's primary key
                    
    // field, and then accept changes on it. Specifically, this is why you turned off EnforceConstraints.
                    args.Row["OrderID"= args.Row.GetParentRow("OrdDetail")["OrderID",DataRowVersion.Original];
                    args.Row.AcceptChanges();
    //上面用了UpdateStatus.SkipCurrentRow,这里为什么还要AcceptChanges(),感觉矛盾.
                    
    // Store the actual primary key value in the foreign key column of the child row.
                    args.Row["OrderID"= currentkey;//为什么又改回原来的值???
                }

                
    if(args.StatementType == StatementType.Delete )
                    args.Status 
    = UpdateStatus.SkipCurrentRow;//这里也不明白它的用意.

    ---------------------------------------------------------------------
    每个人都是一座山.世上最难攀越的山,其实是自己.往上走,即便一小步,也有新高度
    .

    --做最好的自己,我能!!!

  • 相关阅读:
    4.12 IDEA 如何新建 Java 项目 (图文讲解, 良心教程)
    4.11 AndroidStudio快捷键总结
    4.9 Android AndroidX的迁移
    4.8 build.gradle中正确地导入RecyclerView依赖
    4.6 构建之法7
    4.5 构建之法6
    4.4 构建之法5
    4.3 构建之法4
    4.2 构建之法3
    4.1 构建之法2
  • 原文地址:https://www.cnblogs.com/tonyepaper/p/1587764.html
Copyright © 2011-2022 走看看