Ayuda con ADO

Post Reply
User avatar
lafug
Posts: 185
Joined: Thu Nov 17, 2005 12:48 am
Location: Santiago, Chile

Ayuda con ADO

Post by lafug »

Estimados,

Estoy queriendo ejecutar un comando SQL en ADO y me da el error:

Error adodb.command/6 DISP_E_UNKNOWNNAME: EXECUTE

muchas gracias de antemano!!


FUNCTION EJECUTA()
LOCAL oConexionAdo := TOLEAUTO():New("adodb.connection")
LOCAL oComando := TOLEAUTO():New("adodb.command")
LOCAL oRecordset
oConexionAdo:Open("Driver={MySQL ODBC 3.51 Driver};Server="+ALLTRIM(cHost)+";Port=3306;Database="+ALLTRIM(cDataBase)+";User="+ALLTRIM(cUser)+"; Password="+ALLTRIM(cPassword)+";Option=3;")
oComando:ActiveConnection(oConexionAdo)
oComando:CommandText := "SELECT * from AFP"
oRecordSet := oComando:Execute() <------- Aqui me da el error
? oRecordSet
return nil
Luis Alfonso Fuentes Guerrero
FWH 11.06 xHarbour 1.2.1 BCC55 WorkShop
digordo
Posts: 13
Joined: Mon Aug 02, 2010 5:15 pm

Re: Ayuda con ADO

Post by digordo »

lafug, tente desta forma:


Code: Select all | Expand


FUNCTION EJECUTA()
LOCAL oConexionAdo := CreateObject("ADODB.Connection")
LOCAL oRecordSet := CreateObject("ADODB.Recordset")
Local cSQL := "SELECT * from AFP"

oConexionAdo:Open("Driver={MySQL ODBC 3.51 Driver};Server="+ALLTRIM(cHost)+";Port=3306;Database="+ALLTRIM(cDataBase)+";User="+ALLTRIM(cUser)+"; Password="+ALLTRIM(cPassword)+";Option=3;")

oRecordSet:CursorLocation := 3  // adUseClient
oRecordSet:CursorType := 3 // adOpenStatic
oRecordSet:ActiveConnection:= oConexionAdo
oRecordSet:Open(cSQL)

oRecordSet -> Use o record set da forma que desejar

Return
 
User avatar
lafug
Posts: 185
Joined: Thu Nov 17, 2005 12:48 am
Location: Santiago, Chile

Re: Ayuda con ADO

Post by lafug »

Obrigado Digordo!!
Sua dica funcionó
Luis Alfonso Fuentes Guerrero
FWH 11.06 xHarbour 1.2.1 BCC55 WorkShop
Post Reply