Skip to Content
avatar image
Former Member

.Net Connector not using existing open connection.

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Jun 16, 2005 at 11:18 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 16, 2005 at 11:21 AM

    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

    Add comment
    10|10000 characters needed characters exceeded