accesso a database SQL

Moderator: Enrico Maria Giordano

accesso a database SQL

Postby damianodec » Mon Feb 16, 2009 3:05 pm

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
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: accesso a database SQL

Postby Enrico Maria Giordano » Mon Feb 16, 2009 6:44 pm

Sì, via ADO:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: accesso a database SQL

Postby damianodec » Tue Feb 17, 2009 8:06 am

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: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: accesso a database SQL

Postby Enrico Maria Giordano » Tue Feb 17, 2009 8:16 am

Naturalmente devi mettere il tuo DSN con i corretti userid e password.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: accesso a database SQL

Postby damianodec » Tue Feb 17, 2009 8:25 am

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
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: accesso a database SQL

Postby Enrico Maria Giordano » Tue Feb 17, 2009 8:42 am

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

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: accesso a database SQL

Postby damianodec » Tue Feb 17, 2009 9:05 am

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: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Re: accesso a database SQL

Postby damianodec » Tue Feb 17, 2009 9:19 am

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
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Re: accesso a database SQL

Postby Enrico Maria Giordano » Tue Feb 17, 2009 10:06 am

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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: accesso a database SQL

Postby damianodec » Tue Feb 17, 2009 11:32 am

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)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Return to All products support

Who is online

Users browsing this forum: No registered users and 13 guests

cron