Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server Data Access With ADO
Message
De
25/11/1998 15:07:01
 
 
À
25/11/1998 14:40:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00161540
Message ID:
00161556
Vues:
18
>I am trying to use ADO to retrieve data from SQL Server 6.5 to populate ADO record sets instead of using Remote Views in an NTier implementation where the UI may be Fox, or VC++, or possibly even across the Web. Everything works fine until I try to open the record set. When I try to open the record set I either get an OLE Dispatch Error #0, or I get a record set with no records. The test code appears below. If anyone has any thoughts on the subject I would appreciate it.
>
>Thanks
>
>Jason Tryon
>
>
>*********************************************************************
>public oConnect, oRecSet
>
>*/ Create and open the connection
>oConnect = CreateObject("adodb.connection")
>oConnect.Open("MYBOOKLIST")
>
>cSQL = "Select * From booklist"
>
>*/ Create and open the recordset
>oRecSet = CreateObject("adodb.recordset")
>oRecSet.CursorLocation = 3
>*/oRecSet.Open(cSQL,oConnect,3,3) (Generates OLE Dispatch Error)
>oRecSet = oConnect.Execute(cSQL) && Generates a recordset with no records
>
>For nIncr = 0 To oRecSet.Fields.Count - 1
> ? Padr("Field Name = " + oRecSet.Fields(nIncr).Name,35) ;
> + " | Field Type = " + Alltrim(Str(oRecSet.Fields(nIncr).Type))
>EndFor
>?
>? "Record Count = " + Alltrim(Str(oRecSet.RecordCount))
>
>********************************************************************
Try setting the activeconnection property of the recordset object. I tested the following without problems:
oCn=CreateObject("ADODB.Connection")
oRs=CreateObject("ADODB.Recordset")
oCn.Open("DSN=sqltest")
oRs.ActiveConnection = Ocn
oRs.Open("Select * From prdetail")
If oRs.BOF And oRs.EOF
  =MessageBox("Empty Recordset.")
Else
  ? oRs.Fields(5).Value
Endif
oRs.Close
Although I have not played with the cursorlocation property just yet.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform