Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP cursor to ADODB.RecordSet
Message
From
13/07/2006 09:00:00
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01135897
Message ID:
01135995
Views:
11
David,
This might help.
Re: COPY TO command cutting out MEMO Fields Thread #1079707 Message #1080043
You could return the saved .rst file or oRS that opened it (disconnected). It's fast IMHO.
If sql that creates the cursor is simple, I'd directy run it with oCon.Execute to get the oRS.
Cetin

>I'm not able to find this answer anywhere. I've done a lot of code that takes an ADO recordset and converts it to a VFP cursor, but now I've got to find an easy way to go the other direction. Given a VFP cursor convert it directly to a recordset.
>
>This code goes from RS to Cursor:
>
>
>public oRS as ADODB.RecordSet, oCommand as ADODB.command
>
>#DEFINE ADINTEGER   3
>#DEFINE ADCHAR    129
>
>oRS = CreateObject( "ADODB.RecordSet" )
>oRS.CursorLocation = 3
>ors.LockType = 3
>oRS.Fields.Append( "c1", ADCHAR, 100 )
>oRS.Fields.Append( "i1", ADINTEGER, 4 )
>oRS.Open()
>
>oRS.AddNew()
>oRS.Fields("c1").Value = "test1"
>oRS.Fields("i1").Value = 1
>
>oRS.AddNew()
>oRS.Fields("c1").Value = "test2"
>oRS.Fields("i1").Value = 2
>
>oRS.MoveFirst()
>do while ! oRS.EOF()
>   ? alltrim( oRS.Fields("c1").Value ), oRS.Fields("i1").Value
>   oRS.MoveNext()
>enddo
>
>public oCursorAdapter as CursorAdapter
>
>if ( used( "testthis" ) )
>   use in testthis
>endif
>
>oCursorAdapter = createobject( "cursoradapter" )
>oCursorAdapter.DataSourceType ="ADO"
>oCursorAdapter.Alias = "testthis"
>
>oCursorAdapter.DataSource = oRS
>
>? oCursorAdapter.CursorFill( .f., .f., 0, oRS )
>
>select testthis
>scan
>   ? alltrim( c1 ), i1
>endscan
>
>
>this doesn't generate a RS:
>
>
>create cursor testthis ( i1 i, c1 c(10), t1 t, m1 m )
>insert into testthis values ( 1, "test 1", datetime(), "this is my pretty memo" )
>insert into testthis values ( 2, "test 2", datetime(), "this is my prettier memo" )
>
>oRS = CreateObject( "ADODB.RecordSet" )
>oRS.CursorLocation = 3
>oRS.LockType = 3
>
>oCursorAdapter = createobject( "cursoradapter" )
>oCursorAdapter.DataSourceType ="ADO"
>oCursorAdapter.DataSource = oRS
>? oCursorAdapter.CursorAttach( "testthis", .t. )
>
>oRS.MoveFirst()
>do while ! oRS.EOF()
>   ? alltrim( oRS.Fields("c1").Value ), oRS.Fields("i1").Value
>   oRS.MoveNext()
>enddo
>
>
>Ideally I need the RS to construct its field collection structure directly from the cursor structure and then push the data into the RS. The CursorAttach() method returns .t. but oRS is pretty much an empty shell. What am I doing wrong/missing? I don't really want the run a select, it doesn't have to be updateable, it's just a RS that we are passing from a VFP COM object over to an ASP page.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform