Alaska Software Inc. - Connect to ADS
Username: Password:
AuthorTopic: Connect to ADS
VitalyConnect to ADS
on Thu, 06 Oct 2005 08:33:09 +0200
Can i connect to ads via adsdbe with waa?
i try do it with dac session ,but get error 8503
Vladimir IahnencoRe: Connect to ADS
on Thu, 06 Oct 2005 15:42:33 -0400
Hi Vitaly,
Yes you can, but you have to create a new dacSession() for every waa thread 
and close the connection with RETURN TRUE
Else you may create a static Array(WAA_WORKERTHREADS) in _Register(), re-use 
them and disconnect all somewhere in _Deregister()

Regards,
Vladimir

"Vitaly" <rvito@hotmail.com> wrote in message 
news:QbkmjdjyFHA.1256@S15147418...
> Can i connect to ads via adsdbe with waa?
> i try do it with dac session ,but get error 8503
>
Phil Ide
Re: Connect to ADS
on Fri, 07 Oct 2005 12:27:54 +0100
Vitaly,

> Yes you can, but you have to create a new dacSession() for every waa thread 
> and close the connection with RETURN TRUE
> Else you may create a static Array(WAA_WORKERTHREADS) in _Register(), re-use 
> them and disconnect all somewhere in _Deregister()

Here's a simple and optimal technique that works on the fly to create
thread-safe handles:

Function GetThreadSession( lKill)
   STATIC aSession
   local i
   local oSession

   DEFAULT aSession TO {},;
           lKill TO FALSE

   if lKill
      AEVal( aSession, {|e| e[2]:disconnect() } )
   else
      i := AScan( aSession, {|e| e[1] == ThreadId() } )
      if i == 0
         Aadd( aSession, { ThreadId(), CreateSession() } )
         i := AScan( aSession, {|e| e[1] == ThreadId() } )
      endif
      if i > 0
         oSession := aSession[i][2]
      endif
   endif
   return oSession

To use:

   get a session handle
  oSession := GetThreadSession()

   to disconnect all sessions
  GetThreadSession( TRUE )

You need to write the code for CreateSession(), which establishes a
connection to ADS and returns the dacSession object.      

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

If it ain't broke, wait a day or two!!
VitalyRe: Connect to ADS
on Sun, 09 Oct 2005 08:03:47 +0200
Look the code

STATIC Function InitDbf(cName)
 LOCAL oSession,cRet

oSession := dacSession():New( "ADSDBE", "\\prod-nt\sys\test" )

IF ( oSession:isConnected() )
    DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_CDX)
    DbeInfo( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "CDX")

   USE &(cName) NEW SHARED
   cRet := "Was conected"
ELSE
    cRet := str(oSession:getLastError()) //here i get my error
ENDIF

Return  cRet

So,what i need to correct in my code?






"Phil Ide" <phil@xodc.org.uk> wrote in message 
news:n1jmhkud7bna$.dlg@xodc.org.uk...
> Vitaly,
>
>> Yes you can, but you have to create a new dacSession() for every waa 
>> thread
>> and close the connection with RETURN TRUE
>> Else you may create a static Array(WAA_WORKERTHREADS) in _Register(), 
>> re-use
>> them and disconnect all somewhere in _Deregister()
>
> Here's a simple and optimal technique that works on the fly to create
> thread-safe handles:
>
> Function GetThreadSession( lKill)
>   STATIC aSession
>   local i
>   local oSession
>
>   DEFAULT aSession TO {},;
>           lKill TO FALSE
>
>   if lKill
>      AEVal( aSession, {|e| e[2]:disconnect() } )
>   else
>      i := AScan( aSession, {|e| e[1] == ThreadId() } )
>      if i == 0
>         Aadd( aSession, { ThreadId(), CreateSession() } )
>         i := AScan( aSession, {|e| e[1] == ThreadId() } )
>      endif
>      if i > 0
>         oSession := aSession[i][2]
>      endif
>   endif
>   return oSession
>
> To use:
>
>   get a session handle
>  oSession := GetThreadSession()
>
>   to disconnect all sessions
>  GetThreadSession( TRUE )
>
> You need to write the code for CreateSession(), which establishes a
> connection to ADS and returns the dacSession object.
>
> Regards,
> -- 
> Phil Ide
>
> *******************************************
> *   Xbase++ FAQ, Libraries and Sources:   *
> *   goto: http://www.idep.org.uk/xbase    *
> * --------------------------------------- *
> * www.xodc.org.uk - openSource Dev-Center *
> *******************************************
>
> If it ain't broke, wait a day or two!!
Vladimir IahnencoRe: Connect to ADS
on Mon, 10 Oct 2005 11:24:31 -0400
Vitaly,
DbeInfo you have to call once, somewhere in _Register(), when you build 
ADSDBE
In _Register() you also may to check if ADSDBE created and try to establish 
a connection with your server.
I'm not sure if connection string for dacSession():New() is correct, I'm 
using new style connection string
oSession := DacSession():new( "DBE=ADSDBE;SERVER=\\ALASKA\VOL1" )

If you still cannot connect, try to create a small app just to test if you 
can connect, then try to connect in WAA _Register(), then apply this for 
your threads
In WAA thread

MyFunction(oHtml, oContext)
    LOCAL oErrorHandler, o
    oSession := dacSession():New(.....)
    If oSession:IsConnected()
       //I recommend to open databases in BEGIN END SEQUENCE
         you can move this code in a function to open databases
       oErrorHandler := ErrorBlock({||Break(o)})
        BEGIN SEQUENCE
            USE ....
        RECOVER USING o
            oSession:GetLastError()
            oSession:GetLastMessage()
        END
        ErrorBlock(oErrorHandler)
        oSession:Disconnect()
    Else
        //Display an error message
    EndIf
RETURN TRUE


"Vitaly" <rvito@hotmail.com> wrote in message 
news:J7OlocJzFHA.3104@S15147418...
> Look the code
>
> STATIC Function InitDbf(cName)
> LOCAL oSession,cRet
>
> oSession := dacSession():New( "ADSDBE", "\\prod-nt\sys\test" )
>
> IF ( oSession:isConnected() )
>    DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_CDX)
>    DbeInfo( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "CDX")
>
>   USE &(cName) NEW SHARED
>   cRet := "Was conected"
> ELSE
>    cRet := str(oSession:getLastError()) //here i get my error
> ENDIF
>
> Return  cRet
>
> So,what i need to correct in my code?
>
>
>
>
>
>
> "Phil Ide" <phil@xodc.org.uk> wrote in message 
> news:n1jmhkud7bna$.dlg@xodc.org.uk...
>> Vitaly,
>>
>>> Yes you can, but you have to create a new dacSession() for every waa 
>>> thread
>>> and close the connection with RETURN TRUE
>>> Else you may create a static Array(WAA_WORKERTHREADS) in _Register(), 
>>> re-use
>>> them and disconnect all somewhere in _Deregister()
>>
>> Here's a simple and optimal technique that works on the fly to create
>> thread-safe handles:
>>
>> Function GetThreadSession( lKill)
>>   STATIC aSession
>>   local i
>>   local oSession
>>
>>   DEFAULT aSession TO {},;
>>           lKill TO FALSE
>>
>>   if lKill
>>      AEVal( aSession, {|e| e[2]:disconnect() } )
>>   else
>>      i := AScan( aSession, {|e| e[1] == ThreadId() } )
>>      if i == 0
>>         Aadd( aSession, { ThreadId(), CreateSession() } )
>>         i := AScan( aSession, {|e| e[1] == ThreadId() } )
>>      endif
>>      if i > 0
>>         oSession := aSession[i][2]
>>      endif
>>   endif
>>   return oSession
>>
>> To use:
>>
>>   get a session handle
>>  oSession := GetThreadSession()
>>
>>   to disconnect all sessions
>>  GetThreadSession( TRUE )
>>
>> You need to write the code for CreateSession(), which establishes a
>> connection to ADS and returns the dacSession object.
>>
>> Regards,
>> -- 
>> Phil Ide
>>
>> *******************************************
>> *   Xbase++ FAQ, Libraries and Sources:   *
>> *   goto: http://www.idep.org.uk/xbase    *
>> * --------------------------------------- *
>> * www.xodc.org.uk - openSource Dev-Center *
>> *******************************************
>>
>> If it ain't broke, wait a day or two!!
>
>
VitalyRe: Connect to ADS
on Sun, 30 Oct 2005 12:01:32 +0200
I get the error in this "oSession:IsConnected()" (I get the FALSE value) 
line
but if i remove lines with Dac conection and do connect with USE VIA DBFCDX 
only
it work great,but not via ADS connection
And one more problem:when i open table with WAA via dbfcdx ,i can't open it 
in my clipper app via dbxcdxax,
or when i open the table in clipper app,i can't open it in WAA dll?

"Vladimir Iahnenco" <iahnenco@yahoo.com> wrote in message 
news:LepEn6azFHA.5608@S15147418...
> Vitaly,
> DbeInfo you have to call once, somewhere in _Register(), when you build 
> ADSDBE
> In _Register() you also may to check if ADSDBE created and try to 
> establish a connection with your server.
> I'm not sure if connection string for dacSession():New() is correct, I'm 
> using new style connection string
> oSession := DacSession():new( "DBE=ADSDBE;SERVER=\\ALASKA\VOL1" )
>
> If you still cannot connect, try to create a small app just to test if you 
> can connect, then try to connect in WAA _Register(), then apply this for 
> your threads
> In WAA thread
>
> MyFunction(oHtml, oContext)
>    LOCAL oErrorHandler, o
>    oSession := dacSession():New(.....)
>    If oSession:IsConnected()
>       //I recommend to open databases in BEGIN END SEQUENCE
>         you can move this code in a function to open databases
>       oErrorHandler := ErrorBlock({||Break(o)})
>        BEGIN SEQUENCE
>            USE ....
>        RECOVER USING o
>            oSession:GetLastError()
>            oSession:GetLastMessage()
>        END
>        ErrorBlock(oErrorHandler)
>        oSession:Disconnect()
>    Else
>        //Display an error message
>    EndIf
> RETURN TRUE
>
>
> "Vitaly" <rvito@hotmail.com> wrote in message 
> news:J7OlocJzFHA.3104@S15147418...
>> Look the code
>>
>> STATIC Function InitDbf(cName)
>> LOCAL oSession,cRet
>>
>> oSession := dacSession():New( "ADSDBE", "\\prod-nt\sys\test" )
>>
>> IF ( oSession:isConnected() )
>>    DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_CDX)
>>    DbeInfo( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "CDX")
>>
>>   USE &(cName) NEW SHARED
>>   cRet := "Was conected"
>> ELSE
>>    cRet := str(oSession:getLastError()) //here i get my error
>> ENDIF
>>
>> Return  cRet
>>
>> So,what i need to correct in my code?
>>
>>
>>
>>
>>
>>
>> "Phil Ide" <phil@xodc.org.uk> wrote in message 
>> news:n1jmhkud7bna$.dlg@xodc.org.uk...
>>> Vitaly,
>>>
>>>> Yes you can, but you have to create a new dacSession() for every waa 
>>>> thread
>>>> and close the connection with RETURN TRUE
>>>> Else you may create a static Array(WAA_WORKERTHREADS) in _Register(), 
>>>> re-use
>>>> them and disconnect all somewhere in _Deregister()
>>>
>>> Here's a simple and optimal technique that works on the fly to create
>>> thread-safe handles:
>>>
>>> Function GetThreadSession( lKill)
>>>   STATIC aSession
>>>   local i
>>>   local oSession
>>>
>>>   DEFAULT aSession TO {},;
>>>           lKill TO FALSE
>>>
>>>   if lKill
>>>      AEVal( aSession, {|e| e[2]:disconnect() } )
>>>   else
>>>      i := AScan( aSession, {|e| e[1] == ThreadId() } )
>>>      if i == 0
>>>         Aadd( aSession, { ThreadId(), CreateSession() } )
>>>         i := AScan( aSession, {|e| e[1] == ThreadId() } )
>>>      endif
>>>      if i > 0
>>>         oSession := aSession[i][2]
>>>      endif
>>>   endif
>>>   return oSession
>>>
>>> To use:
>>>
>>>   get a session handle
>>>  oSession := GetThreadSession()
>>>
>>>   to disconnect all sessions
>>>  GetThreadSession( TRUE )
>>>
>>> You need to write the code for CreateSession(), which establishes a
>>> connection to ADS and returns the dacSession object.
>>>
>>> Regards,
>>> -- 
>>> Phil Ide
>>>
>>> *******************************************
>>> *   Xbase++ FAQ, Libraries and Sources:   *
>>> *   goto: http://www.idep.org.uk/xbase    *
>>> * --------------------------------------- *
>>> * www.xodc.org.uk - openSource Dev-Center *
>>> *******************************************
>>>
>>> If it ain't broke, wait a day or two!!
>>
>>
>
>
VitalyRe: Connect to ADS
on Sun, 06 Nov 2005 14:45:52 +0200
And one more question were i can see error description for error 8503?
"Vitaly" <rvito@hotmail.com> wrote in message 
news:IIJFejT3FHA.2944@S15147418...
>I get the error in this "oSession:IsConnected()" (I get the FALSE value) 
>line
> but if i remove lines with Dac conection and do connect with USE VIA 
> DBFCDX only
> it work great,but not via ADS connection
> And one more problem:when i open table with WAA via dbfcdx ,i can't open 
> it in my clipper app via dbxcdxax,
> or when i open the table in clipper app,i can't open it in WAA dll?
>
> "Vladimir Iahnenco" <iahnenco@yahoo.com> wrote in message 
> news:LepEn6azFHA.5608@S15147418...
>> Vitaly,
>> DbeInfo you have to call once, somewhere in _Register(), when you build 
>> ADSDBE
>> In _Register() you also may to check if ADSDBE created and try to 
>> establish a connection with your server.
>> I'm not sure if connection string for dacSession():New() is correct, I'm 
>> using new style connection string
>> oSession := DacSession():new( "DBE=ADSDBE;SERVER=\\ALASKA\VOL1" )
>>
>> If you still cannot connect, try to create a small app just to test if 
>> you can connect, then try to connect in WAA _Register(), then apply this 
>> for your threads
>> In WAA thread
>>
>> MyFunction(oHtml, oContext)
>>    LOCAL oErrorHandler, o
>>    oSession := dacSession():New(.....)
>>    If oSession:IsConnected()
>>       //I recommend to open databases in BEGIN END SEQUENCE
>>         you can move this code in a function to open databases
>>       oErrorHandler := ErrorBlock({||Break(o)})
>>        BEGIN SEQUENCE
>>            USE ....
>>        RECOVER USING o
>>            oSession:GetLastError()
>>            oSession:GetLastMessage()
>>        END
>>        ErrorBlock(oErrorHandler)
>>        oSession:Disconnect()
>>    Else
>>        //Display an error message
>>    EndIf
>> RETURN TRUE
>>
>>
>> "Vitaly" <rvito@hotmail.com> wrote in message 
>> news:J7OlocJzFHA.3104@S15147418...
>>> Look the code
>>>
>>> STATIC Function InitDbf(cName)
>>> LOCAL oSession,cRet
>>>
>>> oSession := dacSession():New( "ADSDBE", "\\prod-nt\sys\test" )
>>>
>>> IF ( oSession:isConnected() )
>>>    DbeInfo( COMPONENT_DATA, ADSDBE_TBL_MODE, ADSDBE_CDX)
>>>    DbeInfo( COMPONENT_ORDER, ADSDBE_INDEX_EXT, "CDX")
>>>
>>>   USE &(cName) NEW SHARED
>>>   cRet := "Was conected"
>>> ELSE
>>>    cRet := str(oSession:getLastError()) //here i get my error
>>> ENDIF
>>>
>>> Return  cRet
>>>
>>> So,what i need to correct in my code?
>>>
>>>
>>>
>>>
>>>
>>>
>>> "Phil Ide" <phil@xodc.org.uk> wrote in message 
>>> news:n1jmhkud7bna$.dlg@xodc.org.uk...
>>>> Vitaly,
>>>>
>>>>> Yes you can, but you have to create a new dacSession() for every waa 
>>>>> thread
>>>>> and close the connection with RETURN TRUE
>>>>> Else you may create a static Array(WAA_WORKERTHREADS) in _Register(), 
>>>>> re-use
>>>>> them and disconnect all somewhere in _Deregister()
>>>>
>>>> Here's a simple and optimal technique that works on the fly to create
>>>> thread-safe handles:
>>>>
>>>> Function GetThreadSession( lKill)
>>>>   STATIC aSession
>>>>   local i
>>>>   local oSession
>>>>
>>>>   DEFAULT aSession TO {},;
>>>>           lKill TO FALSE
>>>>
>>>>   if lKill
>>>>      AEVal( aSession, {|e| e[2]:disconnect() } )
>>>>   else
>>>>      i := AScan( aSession, {|e| e[1] == ThreadId() } )
>>>>      if i == 0
>>>>         Aadd( aSession, { ThreadId(), CreateSession() } )
>>>>         i := AScan( aSession, {|e| e[1] == ThreadId() } )
>>>>      endif
>>>>      if i > 0
>>>>         oSession := aSession[i][2]
>>>>      endif
>>>>   endif
>>>>   return oSession
>>>>
>>>> To use:
>>>>
>>>>   get a session handle
>>>>  oSession := GetThreadSession()
>>>>
>>>>   to disconnect all sessions
>>>>  GetThreadSession( TRUE )
>>>>
>>>> You need to write the code for CreateSession(), which establishes a
>>>> connection to ADS and returns the dacSession object.
>>>>
>>>> Regards,
>>>> -- 
>>>> Phil Ide
>>>>
>>>> *******************************************
>>>> *   Xbase++ FAQ, Libraries and Sources:   *
>>>> *   goto: http://www.idep.org.uk/xbase    *
>>>> * --------------------------------------- *
>>>> * www.xodc.org.uk - openSource Dev-Center *
>>>> *******************************************
>>>>
>>>> If it ain't broke, wait a day or two!!
>>>
>>>
>>
>>
>
>