the code is on a method.
The method is executed many times and sometimes im getting error:
"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."
My question is: Is it ok to have the insert and update part together as it is above?
Yes you can do the Insert and Update in same transaction.
One Que : you are doing update opration into Newly Inserted row or some other row??
let me know if any query
this is weird because this method is the only place on the application where there is a double operation(insert/update). And this is the only place where the error occurs.
By the way, im getting the error when implementing the application on another machine.
How can I reproduce the error locally?
I have the application solution and im debugging on Visual Studio 2008.
I mean, Limiting the pool size would help me getting the error locally?
Locally you can host your web site to IIS and Open web site at same time from more then 40 pc (If you are using IIS 5.1 (XP Default IIS), you are not able to connect more then 10 connection), then it may reproduce the error.
If you are doing update opration in newly insered row, I suggest pass updated value at the time of inserting record. you does not need to do the update opration
let me know if any query
Thanks,
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
Marked as answer by piram on Mar 08, 2013 03:30 PM
Locally you can host your web site to IIS and Open web site at same time from more then 40 pc (If you are using IIS 5.1 (XP Default IIS), you are not able to connect more then 10 connection), then it may reproduce the error.
If you are doing update opration in newly insered row, I suggest pass updated value at the time of inserting record. you does not need to do the update opration
piram
Member
127 Points
151 Posts
Connection error
Feb 20, 2013 08:24 PM|LINK
Hi, im using the Enterprise Library to insert and update data to an sql database.
c# code:
Database db = DatabaseFactory.CreateDatabase(); IDbConnection connection = db.GetConnection(); connection.Open(); IDbTransaction transaction = connection.BeginTransaction(); DBCommandWrapper command; try { //insert part command = db.GetStoredProcCommandWrapper("stored_procedure1"); command.CommandTimeout = 900; command.AddInParameter("@parameter1", DbType.Int32, 3); db.ExecuteNonQuery(command, transaction); //update part command = db.GetStoredProcCommandWrapper("stored_procedure2"); command.CommandTimeout = 900; command.AddInParameter("@param1", DbType.Int32, 5); db.ExecuteNonQuery(command, transaction); transaction.Commit(); } finally { connection.Close(); }the code is on a method.
The method is executed many times and sometimes im getting error:
"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."
My question is: Is it ok to have the insert and update part together as it is above?
Thanks.
dhol.gaurav
Contributor
4140 Points
751 Posts
Re: Connection error
Feb 21, 2013 05:05 AM|LINK
Hi,
Yes you can do the Insert and Update in same transaction.
One Que : you are doing update opration into Newly Inserted row or some other row??
let me know if any query
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
piram
Member
127 Points
151 Posts
Re: Connection error
Feb 21, 2013 01:13 PM|LINK
the update operation is made into the newly inserted row.
piram
Member
127 Points
151 Posts
Re: Connection error
Feb 21, 2013 01:24 PM|LINK
this is weird because this method is the only place on the application where there is a double operation(insert/update). And this is the only place where the error occurs.
piram
Member
127 Points
151 Posts
Re: Connection error
Feb 21, 2013 01:32 PM|LINK
By the way, im getting the error when implementing the application on another machine.
How can I reproduce the error locally?
I have the application solution and im debugging on Visual Studio 2008.
I mean, Limiting the pool size would help me getting the error locally?
dhol.gaurav
Contributor
4140 Points
751 Posts
Re: Connection error
Feb 22, 2013 05:28 AM|LINK
Locally you can host your web site to IIS and Open web site at same time from more then 40 pc (If you are using IIS 5.1 (XP Default IIS), you are not able to connect more then 10 connection), then it may reproduce the error.
If you are doing update opration in newly insered row, I suggest pass updated value at the time of inserting record. you does not need to do the update opration
let me know if any query
Gaurav Dhol
Skype ID : dhol.gaurav
If My Post contains helped you, Please Mark as Answer
piram
Member
127 Points
151 Posts
Re: Connection error
Feb 22, 2013 08:23 PM|LINK
.
piram
Member
127 Points
151 Posts
Re: Connection error
Feb 24, 2013 05:27 AM|LINK
.
piram
Member
127 Points
151 Posts
Re: Connection error
Mar 08, 2013 03:30 PM|LINK
Thanks.