zoukankan      html  css  js  c++  java
  • 动态增加SqlParameter[]中的元素,自己的记录

                    sqlsp = "BlogArticle_Update";
                    SqlParameter[] param 
    = {
                                            
    new SqlParameter("Content",Content.Value),
                                        };
                    
    //重构数组
                    SqlParameter[] param2;
                    
    if (IsDefineWeight == "1")
                    {
                        
    int newNum = param.Length + 1;
                        param2 
    = (SqlParameter[])Redim(param, newNum);
                        param2[newNum 
    - 1= new SqlParameter("Weight", weight.Text);
                    }
                    
    else
                    {
                        param2 
    = param;
                    }

                    DAL.dbsp.ExecuteNonQuery(sqlsp, param2);

    自己的记录

            public static Array Redim(Array origArray, Int32 desiredsize)
            {
                
    //确定每个元素类 型    
                Type t = origArray.GetType().GetElementType();
                
    //创建一个含有期望元素个数的新数组  
                
    //新数组的类型必须匹配原数组的类型  
                Array newArray = Array.CreateInstance(t, desiredsize);
                
    //将原数组中的元素拷贝到新数组中  
                Array.Copy(origArray, 0, newArray, 0, Math.Min(origArray.Length, desiredsize));
                
    return newArray;
            }
  • 相关阅读:
    ASP.NET Core 集成 WebSocket
    如何在CentOS7上安装桌面环境?
    Visual Studio 2017 远程调试(Remote Debugger)应用
    cmd sc命令进行服务操作
    EntityFrameworkCode 操作MySql 相关问题
    Windows下安装PHP开发环境
    未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
    System.Runtime.InteropServices.COMException (0x800A03EC): 无法访问文件
    c# WinFo判断当前程序是否已经启动或存在的几种方式
    MVC自定义视图引擎地址
  • 原文地址:https://www.cnblogs.com/yeagen/p/1428871.html
Copyright © 2011-2022 走看看