Una mejor manera de hacer esto es usar el Metodo DataTableAppend() de la clase GetData();
Por ejemplo, si tenemos dos consultas SQL:
Por ejemplo, si tenemos dos consultas SQL:
"SELECT customer_id, customer_name FROM customer WHERE cost_center = 'DIS-A'"
y
"SELECT customer_id, customer_name FROM customer WHERE cost_center = 'CCI'"
con SQL seria:
GetData() gt = new GetData();
gt.SentenciaSQL = "SELECT customer_id, customer_name "
+ "FROM customer WHERE cost_center = 'DIS-A' "
+"UNION ALL "
+ "SELECT customer_id, customer_name "
+ "FROM customer "
+ "WHERE cost_center = 'CCI'";
DataTable dt = gt.GetDataTable();
en cambio con DataTableAppend() sería:
GetData() gt = new GetData();
gt.SentenciaSQL = "SELECT customer_id, customer_name "
+ "FROM customer "
+ "WHERE cost_center = 'DIS-A'"
DataTable dt = gt.GetDataTable();
gt.SentenciaSQL = "SELECT customer_id, customer_name "
+ "FROM customer "
+ "WHERE cost_center = 'CCI'"
dt = gt.DataTableAppend(dt, gt.GetDataTable());
Aunque es un poco mas de código la solución es mas eficiente ya que no mantiene los candados de la base de datos por mucho tiempo.
No hay comentarios.:
Publicar un comentario
Nota: sólo los miembros de este blog pueden publicar comentarios.