1 public DataTable ExecuteDataTable(Sql sql) 2 { 3 return ExecuteDataTable(sql.SQL, sql.Arguments); 4 } 5 public DataTable ExecuteDataTable(string sql, params object[] args) 6 { 7 try 8 { 9 OpenSharedConnection(); 10 try 11 { 12 using (var cmd = CreateCommand(_sharedConnection, sql, args)) 13 { 14 var val = cmd.ExecuteReader(); 15 OnExecutedCommand(cmd); 16 var dt = new DataTable(); 17 dt.Load(val); 18 return dt; //(T)Convert.ChangeType(val, typeof(T)); 19 } 20 } 21 finally 22 { 23 CloseSharedConnection(); 24 } 25 } 26 catch (Exception x) 27 { 28 OnException(x); 29 throw; 30 } 31 }
时间: 2024-12-15 06:50:01