AdsConnect60 works, but now...
Publicado: Vie Oct 01, 2010 10:18 am
I use TAdsDataSource for the remote Advantage server and TCdxDataSource for the standalone without ADS versions and now I want to setup the versions which connect through internet.
What is the quickest and best way for me to do?
I have now for example:
METHOD ConnectToEMS( oSender ) CLASS TFormMain
local hConnect, oError := Nil
::nServerType := asDEFAULT
/* get ServerType registry key */
WITH OBJECT tregistry():Create()
:Root := HKEY_CURRENT_USER
IF :OpenKey( "SoftwareECEMEMS" ) == 0
::nServerType := Val(:GetString( "ServerType" ))
:CloseKey()
ENDIF
:Destroy()
END WITH
::oStatusBar1:aItems[1]:ctext := Alltrim(::oStatusBar1:aItems[1]:ctext) +" - "+ GetServerType()
SWITCH ::nServerType
CASE asDEFAULT
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asLOCAL
ADSSetServerType(ADS_LOCAL_SERVER)
EXIT
CASE asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asAIS
ADSSetServerType(ADS_AIS_SERVER)
EXIT
CASE asREMOTE_AIS
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asANY
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
END
if ::nServerType==asLOCAL
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )
else
REQUEST ADS
RddRegister("ADS",1)
RddSetDefault("ADS")
AdsSetFileType(ADS_CDX)
REQUEST ADSKEYCOUNT, ADSKEYNO, ADSGETRELKEYPOS, ADSSETRELKEYPOS
endif
AdsRightsCheck(.F.)
AdsLocking(.F.)
/* check for connection */
if ::nServerType==asREMOTE
/* ADS */
IF AdsConnect("Emsads", ::nServerType)
WITH OBJECT ::oCdx
:cConnect := ::cDataPath
:nServerType := ::nServerType
END WITH
WITH OBJECT ::oCdxMain
:cConnect := ::cDataPath
:nServerType := ::nServerType
END WITH
ELSE
MsgStop("Cannot establish an ADS connection!")
QUIT
ENDIF
elseif ::nServerType==asAIS
/* AIS */
IF AdsConnect60( ::cDataPath+"EMSAIS.add",ADS_AIS_SERVER,"xxxx","xxxx")
WITH OBJECT ::oCdx
:cConnect := ::cDataPath+"EMSAIS.add"
:cUser := "xxxx"
:cPassword := "xxxx"
:lUseDictionary := .t.
:nServerType := ::nServerType
END WITH
WITH OBJECT ::oCdxMain
:cConnect := ::cDataPath+"EMSAIS.add"
:cUser := "xxxx"
:cPassword := "xxxx"
:lUseDictionary := .t.
:nServerType := ::nServerType
END WITH
ELSE
//MsgInfo(AdsGetLastError())
MsgStop("Cannot establish an AIS connection!")
QUIT
ENDIF
else
/* local without ADS */
endif
RETURN Nil
METHOD DBFCreate( oSender ) CLASS TLogIn
WITH OBJECT oSender
:oDataSource := GetCDXMainDataSource()
:lOpen := .t.
END WITH
RETURN Nil
FUNCTION GetCDXMainDataSource()
LOCAL oDataSource := Nil, nType := Application:oMainForm:nServerType
/*
oCdx ==> TAdsDataSource
oCdxMain ==> TAdsDataSource
oCdxLocal ==> TCdxDataSource
oCdxMainLocal ==> TCdxDataSource
*/
SWITCH nType
CASE asDEFAULT
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asLOCAL
oDataSource := Application:oMainForm:oCdxMainLocal
EXIT
CASE asREMOTE
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asAIS
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asREMOTE_AIS
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asANY
oDataSource := Application:oMainForm:oCdxMain
EXIT
END
RETURN oDataSource
How do I simple make it work with AIS with above code? Or do I have to setup it completely different? I know I have to use the 'use'-command, but how do I pass the cVarName for alias()
Thx in advantage!
Maarten
What is the quickest and best way for me to do?
I have now for example:
METHOD ConnectToEMS( oSender ) CLASS TFormMain
local hConnect, oError := Nil
::nServerType := asDEFAULT
/* get ServerType registry key */
WITH OBJECT tregistry():Create()
:Root := HKEY_CURRENT_USER
IF :OpenKey( "SoftwareECEMEMS" ) == 0
::nServerType := Val(:GetString( "ServerType" ))
:CloseKey()
ENDIF
:Destroy()
END WITH
::oStatusBar1:aItems[1]:ctext := Alltrim(::oStatusBar1:aItems[1]:ctext) +" - "+ GetServerType()
SWITCH ::nServerType
CASE asDEFAULT
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asLOCAL
ADSSetServerType(ADS_LOCAL_SERVER)
EXIT
CASE asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asAIS
ADSSetServerType(ADS_AIS_SERVER)
EXIT
CASE asREMOTE_AIS
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asANY
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
END
if ::nServerType==asLOCAL
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )
else
REQUEST ADS
RddRegister("ADS",1)
RddSetDefault("ADS")
AdsSetFileType(ADS_CDX)
REQUEST ADSKEYCOUNT, ADSKEYNO, ADSGETRELKEYPOS, ADSSETRELKEYPOS
endif
AdsRightsCheck(.F.)
AdsLocking(.F.)
/* check for connection */
if ::nServerType==asREMOTE
/* ADS */
IF AdsConnect("Emsads", ::nServerType)
WITH OBJECT ::oCdx
:cConnect := ::cDataPath
:nServerType := ::nServerType
END WITH
WITH OBJECT ::oCdxMain
:cConnect := ::cDataPath
:nServerType := ::nServerType
END WITH
ELSE
MsgStop("Cannot establish an ADS connection!")
QUIT
ENDIF
elseif ::nServerType==asAIS
/* AIS */
IF AdsConnect60( ::cDataPath+"EMSAIS.add",ADS_AIS_SERVER,"xxxx","xxxx")
WITH OBJECT ::oCdx
:cConnect := ::cDataPath+"EMSAIS.add"
:cUser := "xxxx"
:cPassword := "xxxx"
:lUseDictionary := .t.
:nServerType := ::nServerType
END WITH
WITH OBJECT ::oCdxMain
:cConnect := ::cDataPath+"EMSAIS.add"
:cUser := "xxxx"
:cPassword := "xxxx"
:lUseDictionary := .t.
:nServerType := ::nServerType
END WITH
ELSE
//MsgInfo(AdsGetLastError())
MsgStop("Cannot establish an AIS connection!")
QUIT
ENDIF
else
/* local without ADS */
endif
RETURN Nil
METHOD DBFCreate( oSender ) CLASS TLogIn
WITH OBJECT oSender
:oDataSource := GetCDXMainDataSource()
:lOpen := .t.
END WITH
RETURN Nil
FUNCTION GetCDXMainDataSource()
LOCAL oDataSource := Nil, nType := Application:oMainForm:nServerType
/*
oCdx ==> TAdsDataSource
oCdxMain ==> TAdsDataSource
oCdxLocal ==> TCdxDataSource
oCdxMainLocal ==> TCdxDataSource
*/
SWITCH nType
CASE asDEFAULT
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asLOCAL
oDataSource := Application:oMainForm:oCdxMainLocal
EXIT
CASE asREMOTE
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asAIS
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asREMOTE_AIS
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asANY
oDataSource := Application:oMainForm:oCdxMain
EXIT
END
RETURN oDataSource
How do I simple make it work with AIS with above code? Or do I have to setup it completely different? I know I have to use the 'use'-command, but how do I pass the cVarName for alias()
Thx in advantage!
Maarten