C#实现C/S架构下的TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构(4)

来源:网络整理 责任编辑:栏目编辑 发表时间:2013-07-02 05:57 点击:

   return cmd;
  }
  #endregion

  #region ExecuteNonQueryTypedParams
  /// <summary>
  /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the database specified in
  /// the connection string using the dataRow column values as the stored procedure's parameters values.
  /// This method will query the database to discover the parameters for the
  /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
  /// </summary>
  /// <param name="connectionString">A valid connection string for a SqlConnection</param>
  /// <param name="spName">The name of the stored procedure</param>
  /// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
  /// <returns>An int representing the number of rows affected by the command</returns>
  public static int ExecuteNonQueryTypedParams(String connectionString, String spName, DataRow dataRow)
  {
   if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );
   if( spName == null || spName.Length == 0 ) throw new ArgumentNullException( "spName" );
   
   // If the row has values, the store procedure parameters must be initialized
   if (dataRow != null && dataRow.ItemArray.Length > 0)
   {
    // Pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
    SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName);
               
    // Set the parameters values
    AssignParameterValues(commandParameters, dataRow);
                               
    return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
   }
   else
   {
    return SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
   }
  }

  /// <summary>
  /// Execute a stored procedure via a SqlCommand (that returns no resultset) against the specified SqlConnection
  /// using the dataRow column values as the stored procedure's parameters values. 
  /// This method will query the database to discover the parameters for the
  /// stored procedure (the first time each stored procedure is called), and assign the values based on row values.
  /// </summary>
  /// <param name="connection">A valid SqlConnection object</param>
  /// <param name="spName">The name of the stored procedure</param>
  /// <param name="dataRow">The dataRow used to hold the stored procedure's parameter values.</param>
  /// <returns>An int representing the number of rows affected by the command</returns>
  public static int ExecuteNonQueryTypedParams(SqlConnection connection, String spName, DataRow dataRow)
  {
   if( connection == null ) throw new ArgumentNullException( "connection" )

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • 用C#制作屏幕捕获程序
    • .NET程序员项目开发必知必会—Dev环境中的集成测试用例执行时上
    • 遍历ArrayList易犯错误
    • C#对XML操作:一个处理XML文件的类(1)
    • .NET简谈反射(动态调用)
    • 使用C#编写LED样式时钟控件
    • DataList嵌套问题 如何删除内层子DataList的记录
    • 怎样用C#实现完整文档打印功能
    • .NET简谈自定义事务资源管理器
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1