Пример #1
0
 /// <summary>
 /// 执行命令
 /// </summary>
 public override void ExecuteCommand()
 {
     try
     {
         CommandInstance.CommandText = SqlCommandText;
         CommandInstance.Connection  = ConnectionInstance;
         ConnectionInstance.Open();
         if (SqlParametersInstance != null && SqlParametersInstance.Count > 0)
         {
             foreach (SqlParameter parameter in SqlParametersInstance)
             {
                 SqlParameter copyParameter = (SqlParameter)((ICloneable)parameter).Clone();
                 CommandInstance.Parameters.Add(copyParameter);
             }
         }
         SqlDataOperationRecord = CommandInstance.ExecuteNonQuery();
         ConnectionInstance.Close();
     }
     catch (Exception exception)
     {
         base.SettingOperattionMessage(exception.Message);
     }
     SettingCommandText(string.Empty);
     CommandInstance.Parameters.Clear();
     SqlParametersInstance.Clear();
 }
Пример #2
0
 /// <summary>
 /// 数据读取器
 /// </summary>
 /// <returns></returns>
 public override DbDataReader ExecuteReader()
 {
     try
     {
         CommandInstance.CommandText = SqlCommandText;
         CommandInstance.Connection  = ConnectionInstance;
         ConnectionInstance.Open();
         if (SqlParametersInstance != null)
         {
             if (SqlParametersInstance.Count > 0)
             {
                 CommandInstance.Parameters.AddRange(SqlParametersInstance.ToArray());
             }
         }
         this.reader = CommandInstance.ExecuteReader();
         ConnectionInstance.Close();
     }
     catch (Exception ex)
     {
         base.SettingOperattionMessage(ex.Message);
     }
     SettingCommandText(string.Empty);
     CommandInstance.Parameters.Clear();
     SqlParametersInstance.Clear();
     return(this.reader);
 }