accesso a database SQL

Moderator: Enrico Maria Giordano

Post Reply
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

accesso a database SQL

Post by damianodec »

Ad un server con SQL accedevo tramite ODBC con l'istruzione
oOdbc := TOdbc():New( cDSN, cName, cPass )
e mi tiravo la mia query con:
oDbf := oOdbc:Query(.....)

il responsabile del server dopo un aggiornamento non riesce ad attivare più l'ODBC, di conseguenza non funziona più la mi a procedura.
C'è qualche altro modo per accedervi?
grazie
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: accesso a database SQL

Post by Enrico Maria Giordano »

Sì, via ADO:

Code: Select all

#define adOpenForwardOnly 0
#define adOpenKeyset      1
#define adOpenDynamic     2
#define adOpenStatic      3

#define adLockReadOnly        1
#define adLockPessimistic     2
#define adLockOptimistic      3
#define adLockBatchOptimistic 4


FUNCTION MAIN()

    LOCAL oRs := CREATEOBJECT( "ADODB.Recordset" )

    oRs:Open( "SELECT * FROM Clienti ORDER BY Cliente", "Dsn=Clienti;Uid=Userid;Pwd=Password", adOpenForwardOnly, adLockOptimistic )

    WHILE !oRs:EOF
        ? oRs:FIELDS( "Cliente" ):Value
        oRs:MoveNext()
    ENDDO

    oRs:Close()

    RETURN NIL
EMG
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: accesso a database SQL

Post by damianodec »

provo, ma mi da l'errore:

Error description: Error ADODB.Recordset/6 DISP_E_UNKNOWNNAME: OPEN
Called from: win32ole.prg => TOLEAUTO:OPEN(0)
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: accesso a database SQL

Post by damianodec »

HO FATTO:

#define adOpenForwardOnly 0
#define adOpenKeyset 1
#define adOpenDynamic 2
#define adOpenStatic 3

#define adLockReadOnly 1
#define adLockPessimistic 2
#define adLockOptimistic 3
#define adLockBatchOptimistic 4
local cDsn := "cDsn"
Local cName := "cName"
Local cPass := "cPass"
LOCAL oRs := CREATEOBJECT( "ADODB.Recordset" )

oRs:Open( " Select t0.Name, T5.condpag, t0.address, t0.zipcode, t0.fax, t0.city, t0.county "+ ;
"from CLIENTI t0 INNER JOIN CLIENTI1 T5 "+ ;
"ON T0.KEY = T5.KEY where T0.NAME = 'NOME CLIENTE'", ;
"Dsn=CDsn;Uid=cCname;Pwd=cPass", adOpenForwardOnly, adLockOptimistic )

naturalmente in cDsn c'è il nome del database in cname l'userid e in cpass la password
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: accesso a database SQL

Post by Enrico Maria Giordano »

Per favore, visualizza la seguente stringa e ti renderai conto dell'errore:

? "Dsn=CDsn;Uid=cCname;Pwd=cPass"

EMG
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: accesso a database SQL

Post by damianodec »

il secondo parametro come errore è:
[ 2] = C Dsn=nomeDB;Uid=utente;Pwd=password
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: accesso a database SQL

Post by damianodec »

posso inviarti l'esempio via email?
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: accesso a database SQL

Post by Enrico Maria Giordano »

Ho visto. Se sei assolutamente certo che sia la query (SELECT etc.) sia Dsn, Uid e Pwd siano corretti allora temo che il database non sia proprio accessibile.

EMG
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: accesso a database SQL

Post by damianodec »

la query è quella che andava bene con l'ODBC e Dsn Uid e Pwd son quelli.... sigh!
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Post Reply