Note that there are some explanatory texts on larger screens.

plurals
  1. POsubsonic 3.0.0.3 times out on multiple save operations. MSSQL2005
    primarykey
    data
    text
    <p>I'm reading a csv file and insert the information in a sql 2005 database.</p> <p>After about 250 object.save operations, it times out. here the code and the exact error message. this is not the first version of the code but it always give the same time out.</p> <p>This is not a big database, only 2 tables. Is there something I'm not doing ? Does it open and close a connection for every save operation. All input on that problem is welcome.</p> <pre><code>List&lt;shipment&gt; oLstShipments = new List&lt;shipment&gt;(); while (oReader.ReadNextRecord()) { int iIdShipment; if (int.TryParse(oReader[0], out iIdShipment)) { shipment oShipment = new shipment(); oShipment.idShipment = iIdShipment; oShipment.dateDelivered = oReader[1]; oShipment.inventoryGroup = oReader[2]; oShipment.companyId = oReader[3]; oShipment.shipTo = oReader[4]; oShipment.carrier = oReader[5]; oShipment.accountOwner = oReader[6]; oShipment.accountNumber = oReader[7]; oShipment.trackingNumber = oReader[8]; oLstShipments.Add(oShipment); } } oReader.Dispose(); oSR.Dispose(); foreach (shipment oShip in oLstShipments) { oShip.Save(); } </code></pre> <p>the error :</p> <pre><code>System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at SubSonic.DataProviders.DbDataProvider.CreateConnection(String connectionString) at SubSonic.DataProviders.DbDataProvider.CreateConnection() at SubSonic.DataProviders.AutomaticConnectionScope..ctor(IDataProvider provider) at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) at SubSonic.Repository.SubSonicRepository`1.Add(T item, IDataProvider provider) at invoiceRetriever.Data.shipment.Add(IDataProvider provider) in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\ActiveRecord.cs:line 516 at invoiceRetriever.Data.shipment.Save(IDataProvider provider) in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\ActiveRecord.cs:line 531 at invoiceRetriever.Data.shipment.Save() in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\ActiveRecord.cs:line 525 at invoiceRetriever.frmHaasFiles.cmdProcess_Click(Object sender, EventArgs e) in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\frmFiles.cs:line 59 </code></pre> <p>Test #1</p> <pre><code>for (int i = 1; i &lt; 200; i++) { try { shipment oShipment = new shipment(); oShipment.idShipment = i; oShipment.dateDelivered = "10/10/2009"; oShipment.inventoryGroup = "123"; oShipment.companyId = "1"; oShipment.shipTo = "shipToTest"; oShipment.carrier = "carrierTest"; oShipment.accountOwner = "me"; oShipment.accountNumber = "123456"; oShipment.trackingNumber = "track001"; oShipment.Save(); } catch (Exception ex) { MessageBox.Show("failed at #: " + i + Environment.NewLine + ex.ToString()); break; } } </code></pre> <p>Exception raised: </p> <pre><code>failed at #: 267 System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at SubSonic.DataProviders.DbDataProvider.CreateConnection(String connectionString) at SubSonic.DataProviders.DbDataProvider.CreateConnection() at SubSonic.DataProviders.AutomaticConnectionScope..ctor(IDataProvider provider) at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) at SubSonic.Repository.SubSonicRepository`1.Add(T item, IDataProvider provider) at invoiceRetriever.Data.shipment.Add(IDataProvider provider) in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\ActiveRecord.cs:line 516 at invoiceRetriever.Data.shipment.Save(IDataProvider provider) in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\ActiveRecord.cs:line 531 at invoiceRetriever.Data.shipment.Save() in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\ActiveRecord.cs:line 525 at invoiceRetriever.frmHaasFiles.cmdProcess_Click(Object sender, EventArgs e) in D:\programmation\ceb\invoiceRetriever\invoiceRetriever\frmHaasFiles.cs:line 50 </code></pre> <p>If I try to detach the db, it's gonna say 101 active connections (1 for the management studio and the rest the code.)</p> <p>If I try with the list with the repo like I did previously I get this exception : System.Data.SqlClient.SqlException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Too many parameters were provided in this RPC request. The maximum is 2100.</p> <p>I'm pretty sure I do something wrong, I can't be the only one that wants to insert so many items in the db.</p> <p>EDIT 12/13/2009 09:44:00 : </p> <p>Here is the script to create the shipment table.</p> <pre><code>/****** Object: Table [dbo].[shipment] Script Date: 12/11/2009 14:33:23 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[shipment]( [idShipment] [int] NOT NULL, [dateDelivered] [varchar](255) NULL, [inventoryGroup] [varchar](255) NULL, [companyId] [varchar](255) NULL, [shipTo] [varchar](255) NULL, [carrier] [varchar](255) NULL, [accountOwner] [varchar](255) NULL, [accountNumber] [varchar](255) NULL, [trackingNumber] [varchar](255) NULL, [cebnowaybill] [varchar](50) NULL, CONSTRAINT [PK_shipment] PRIMARY KEY CLUSTERED ( [idShipment] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload