cancel
Showing results for 
Search instead for 
Did you mean: 

.Net Connector not using existing open connection.

Former Member
0 Kudos

Hi All,

We have made an application in VS.Net which calls BAPI's in SAP R/3(4.6B) using SAP .NET connector.

The problem we are facing is that everytime we call a BAPI it creates a new connection without checking if any existing connection is open or not.

We dont need to open the connection, BAPI call (from VS.NET) opens a new connection on every call.

Due to this every time a new connection is opened.

When we viewed these connections using TXN smgw the no. of connection keeps on increasing on every BAPI call from VS.NET.

It only closes the connection when we explicitly close it from VS.NET "connection.close" function.

Any ideas about why it always uses a new connection.

Regards,

Stephen

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

what you described is by design. If you don't use the built-in connection pooling feature, or keep an open connection in your app for re-use, you need to explicitly close or dispose the connection after the use.

The .NET Connector 2.0 documentation has an excellent description on the topic "Managing Connections Lifetime ".

Regards,

Guangwei Li

reiner_hille-doering
Active Contributor
0 Kudos

Connection management is usually completely in your hand.

proxy.Connection = new SAPConnection(...)

...

allways opens a new connection that you need to close.

There are some helper features that allow you to pool connections:

proxy.Connection = Connection.GetConnectionFromPool(...)

...

Connection.ReturnConnection (proxy.Connection);

This would pool connections.

You can also use AutoPooling. Configure is (see online help for the AutoPooling property) and call

proxy.Connection = Connection.GetConnection(...);

...

proxy.Connection.Dispose();

This is also the strategy that the designer-generated code in Windows Forms takes (except the fact the Dispose is called automatically).

For WebForms we have a similar approach with Login Forms that can also be used with AutoPooling.