Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Aprendendo ADO
Message
From
18/09/2002 08:37:33
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Aprendendo ADO
Miscellaneous
Thread ID:
00701704
Message ID:
00701704
Views:
91
Olá grupo.

Eu estou começando a estudar como se usam conexões, recordSets e Comandos ADO. Para estudar, estou usando isso numa base de dados feita no próprio VFP.
Meu objetivo com esse teste é acessar uma Stored Procedure que faz a geração automática de PK's. Estou usando o seguinte código:
oConn = CREATEOBJECT([AdoDB.Connection])
oRS = CREATEOBJECT([AdoDB.recordSet])
oCmd = CREATEOBJECT([AdoDB.Command])
*-- Parâmetro OUTPUT da SP = lnId
*-- Valor de OutPut para oPrm1.Direction = 2
*-- Parâmetro INPUT da SP = tcCampo
*-- Valor de Input para oPrm2.Direction = 1
lcConnString = [Provider = VFPOleDB.1; Data Source = d:\TESTE\MEUBD.DBC]
oConn.CursorLocation = 2  && adUseServer
oCOnn.Mode = 16  && adModeShareDenyNone
oConn.Open(lcConnString)
oCmd.CommandType = 4 && Stored Procedure
oCmd.CommandText = [_st_GeraId] && Nome da Procedure
oPrm1 = oCmd.CreateParameter()
oPrm1.Name = [lnId]
oPrm1.Type = 3  && adInteger
oPrm1.Direction = 2
oPrm1.Size = 4 && bytes
oPrm1.Value = 0 && inicializei o valor de retorno.
oCmd.Parameters.Append(oPrm1)
oCmd.CreateParameter()
oPrm2 = oCmd.CreateParameter()
oPrm2.Name = [tcCampo]
oPrm2.Type = 200  && adVarChar
oPrm2.Direction = 1 && input Parameter
oPrm2.Size = 25 && Um campo pode ter no máximo 25 caracteres, neste caso específico
oPrm2.Value = [MinhaPK]
oCmd.Parameters.Append(oPrm2) && Anexando outro parâmetro ao objeto oCmd
oCmd.Execute() && Para executar o Comando
Esse código está me retornando o seguinte OLE ERROR:

OLE IDispatch Exception code 0 From ADODB.Command: The connection cannot be used to perform this operation. It is either closed or invalid in this context...

O que eu fiz errado?

Grato...
Pablo Márcio de Oliveira

Inside the scream is silent, inside it must remain
Next
Reply
Map
View

Click here to load this message in the networking platform