buenas tardes que tal
que diferencia o ventajas hay en este codigo en abrir y cerrar coneccion al realizar una consulta
codigo abriendo y cerrando coneccion
DataSet ds_l = new DataSet();
TdConnection conn = new TdConnection("ruta de conexion");
TdDataAdapter adapter = new TdDataAdapter();
conn.Open();
adapter.SelectCommand = new TdCommand("SELECT * from tabla, conn);
adapter.Fill(ds_l, "Source");
conn.Close();
-----------------------
o colocar el codigo sin colocarle que abra y cierre la coneccion
DataSet ds_l = new DataSet();
TdConnection conn = new TdConnection("ruta de conexion");
TdDataAdapter adapter = new TdDataAdapter();
adapter.SelectCommand = new TdCommand("SELECT * from tabla, conn);
adapter.Fill(ds_l, "Source");
---------------------------------------------------
estoy utilizando .net c# y base de datos teradata, el cual me funcionaba el codigo sin colocarle abrir y cerrar coneccion, pero presento un caso dias despues me presento el error
Teradata.Client.Provider.TdException: [.NET Data Provider for Teradata] [100001] Cannot close an Active Request. Please Abort the Request. at Teradata.Client.Provider.Request.Close() at Teradata.Client.Provider.Connection.ReturnRequest(Request request) at Teradata.Client.Provider.TdCommand.ReleaseRequest() at Teradata.Client.Provider.TdCommand.HandleExecuteException(TdException eOuter) at Teradata.Client.Provider.TdCommand.ExecuteRequest(CommandBehavior cmdBehavior, Boolean asynchronousCall) at Teradata.Client.Provider.TdCommand.ExecuteReader(CommandBehavior behavior) at Teradata.Client.Provider.TdCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)