Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote Views in Code

Status
Not open for further replies.

stanlyn

Programmer
Sep 3, 2003
945
US
Hi,

Having some issues with using remote views in .prg and object events code. I'm new to this whole remote view stuff. Creating a form with a remote view as its data source is working as expected, however when I close the form remote view data is also closed. It makes sense for this to be normal behavior. Some questions...

1. I have only been able to add data using the append and replace commands on the form. Issuing an "insert into" statement fails the debugger.

2. After doing a append blank, stuffing data, followed with a tableupdate() does insert the data but when closing the form I get the ???? revert option. If I use tableupdate(.T.,.T.) I don't get the revert data option. Isn't (.T.,.T) a bit extreme with only a single user, me?

I see by manually browsing a remote view via the gui, it inserts into the command window these three lines,
Code:
use remoteview again in 0
select remoteview
browse

which suggests as the way to use them via code. I've had issues in getting a stable predictable behavior. Right now, I'm getting a program error "G:\path\remoteview.dbf does not exist." after using the exact code the manual browsing process places in the command window. I get this after issuing a tableupdate() than a form release, which drops me back to the calling program as expected. Then I close the main program and get this error from the shutdon code in which I am using the commands the manual browse uses.

I was previously using sql passthru and is just too much work to use in an entire app, so I went looking for an easier way that closely mimics vfp's data engine and commands. Looks like remote views could be the answer, if I can only get a handle on how to use it, such as when to requery(), tableupdate(), using thein in forms, .prgs and ??
snip1_royk7r.jpg

Any explanations would be appreciated,
Stanley
 
Hi,

I found that
Code:
database!remoteview
(adding the database name helps...

Thanks,
Stanley
 
Okay, self-solved.

Indeed the echoing of commands is not a blueprint of what's needed. Views can be used like a DBC table by database!tablename or you SET DATABASE TO the view database and then don't need the database! prefix.

But you had more questiosn:

1. Views are defined by SELECTs only. Insrts, Updates, Deletes are generated once you define key field, updatabale fields and such info. You don't write them. TABLEUPDATE does that.

2. Hard to say what was going wrong. But you should know that VFP doesn't like to cloase a view wit uncommitted buffered changes and then asks, whether you want to revert them. So before closing a view workarea should always check for buffered changes. See the GETNEXTMODIFIED() help topic.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top