Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server Data Access With ADO
Message
From
25/11/1998 15:07:01
 
 
To
25/11/1998 14:40:08
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00161540
Message ID:
00161556
Views:
17
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform