Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to ADO?
Message
From
18/09/2002 08:40:52
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
How to ADO?
Miscellaneous
Thread ID:
00701705
Message ID:
00701705
Views:
61
Hi group.

I'm now learning how to use ADO connections, recordSets and Commands. To use this, i'm testing on a VFP-made Database, just to learn how ADO works.
This code should access a PK-Generation Stored Procedure in the DB. I'm using the following code for tests:
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
This Code returns me:

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...

What's going on? Did I forget anything?

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