public DataTable Execute()
 {
     if (SqlConnection == null)
     {
         return(null);
     }
     else if (CommandInstance == null)
     {
         return(null);
     }
     else
     {
         var reader = CommandInstance.ExecuteReader();
         if (reader.HasRows)
         {
             var dataTable = new DataTable();
             dataTable.Load(reader);
             reader.Close();
             return(dataTable);
         }
         else
         {
             reader.Close();
             return(null);
         }
     }
 }
示例#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);
 }