Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tim Lawrence
  Where is Tim Lawrence?
 Duluth
 Georgia - United States
 Tim Lawrence
 To: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 Tags
Subject: RE: too many connection
Thread ID: 267684 Message ID: 268678 # Views: 27 # Ratings: 0
Version: Visual FoxPro 9 Category: ODBC, ADO and OLEDB
Date: Tuesday, July 13, 2010 11:30:42 PM         
   


Anders,

This is related since we're talking about connections, but I created methods to re-create a connection before the CursorFill, CursorRefresh, CursorUpdate, etc. As soon as the calls to SQL were complete, I used SQLDISCONNECT.

My first CursorFill(.T.) was just fine (no Data) and an empty cursor was created as expected. But when the CursorRefresh was fired, the connection is created in BeforeCursorRefresh and then i see AfterCursorRefresh and lResult=.F. AERROR returns that the connection string is invalid, even though it is identical to the one I create initially. Same DataSource (DE) and DataSourcetype (ODBC). UseDEDataSource=.T.

Any suggestions?


> >
> >
> >
> > ODBC
>
>
> SQLCONNECT(nStementHandle)
>
> Remarks
> nStatementHandle
> Specifies that a new statement handle be created for the underlying shared connection that is represented by nStatementHandle. The new statement handle uses the settings provided from nStatementHandle instead of using the default settings.
> nStatementHandle
>
>
> Remarks
>
> The SQLCONNECT( ) and SQLSTRINGCONNECT( ) functions return a numeric value as the statement handle rather than a connection handle. You cannot obtain a connection handle directly. You can still set and get connection properties using the SQLSETPROP( ) and SQLGETPROP( ) functions by passing the statement handle for that connection and the string, "Shared", as arguments. All other SQL functions use a statement handle instead of a connection handle.
>
>
> SQLSTRINGCONNECT([lShared] | [cConnectString [, lSharable]])
> Remarks
> SQLSTRINGCONNECT( ) always creates a new connection when it successfully makes a connection. However, setting the lShared parameter determines whether you can share the connection later. If you specify a connection as shareable by setting lShared to True (.T.), you can share the connection later by calling SQLCONNECT( ) and passing the numeric value of the connection handle as the first parameter. For more information, see SQLCONNECT( ) Function.
>
> You can use SQLCONNECT( ) to obtain a new statement handle on a shared connection that was opened using SQLSTRINGCONNECT( ).
>
>

>
> In other words if you have a connection 2 and do
> xx = SQLCONNECT(2) && and 2 is a shared and sharable connection
> then xx will be a new handle on the same connection. So all your CA objects can use a single connection, but different statement handles.
>
> As you're using VFP9, see also SQLIDLEDISCONNECT().
>
> Pooling is an additional way of saving resources between differnet users. It's not an automatic default feature of ODBC.
>
> -Anders

ENTIRE THREAD

too many connection Posted by khubaib khalid @ 7/6/2010 12:31:56 PM
RE: too many connection Posted by Mike Gagnon @ 7/6/2010 12:46:58 PM
RE: too many connection Posted by khubaib khalid @ 7/6/2010 1:43:37 PM
RE: too many connection Posted by Mike Gagnon @ 7/6/2010 2:42:10 PM
RE: too many connection Posted by Anders Altberg @ 7/6/2010 1:20:58 PM
RE: too many connection Posted by khubaib khalid @ 7/6/2010 1:46:05 PM
RE: too many connection Posted by Anders Altberg @ 7/6/2010 3:22:33 PM
RE: too many connection Posted by Tim Lawrence @ 7/13/2010 11:30:42 PM