Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Andy Kramek
  Where is Andy Kramek?
 Westminster Circle, Akron
 Ohio - United States
 Andy Kramek
 To: pandurang chavan
  Where is pandurang chavan?
 india
 India
 pandurang chavan
 Tags
Subject: RE: ODBC View update sql server
Thread ID: 232019 Message ID: 232074 # Views: 26 # Ratings: 1
Version: Visual FoxPro 9 Category: ODBC, ADO and OLEDB
Date: Friday, June 19, 2009 1:01:07 PM         
   


> HI..
> how to update view from visual foxpro to sql server..
> I can write the in view but it is not updating in sql server table.
> I want to update related sql server Table.
>
> Thanks in Advance..
>
> Pandurang S.chavan

First you need a connection so that you can read the data from SQL.

Next, in your view you must set SendUpdates = .T. (There is a checkbox inthe view designer at bottom left of the "Update Criteria" tab

Third your view MUST identify, in the update criteria the primary key for updates

Fourth, you must have at least one column flagged as updatable (again, the update criteria tab)

Fifth, set the WHERE clause options properly - if you are using surrogate primary keys (and why not?) then you should just use "Key Fields Only"

When all that is in place, TableUpdate() will work for a remote view.

Having said all that, this is NOT the best way to do this. You should either use a CursorAdapter, or SQL Passthrough, in preference to Remote Views. If you are not sure about CursorAdapters, see Bernard's excellent tutorials in the forum Articles section:

http://www.foxite.com/articles/read.aspx?id=49&document=creating-using-cursor-adapter-classes-a-simple-tutorial
http://www.foxite.com/articles/read.aspx?id=53&document=creating-using-ca-classes-a-simple-tutorial-part-ii
http://www.foxite.com/articles/read.aspx?id=54&document=creating-using-ca-classes-a-simple-tutorial-part-iia

Regards
Andy Kramek
Microsoft MVP (Visual FoxPro)
Tightline Computers Inc, Akron Ohio, USA



COMPLETE THREAD
ODBC View update sql server Posted by pandurang chavan @ 6/19/2009 2:17:49 AM
RE: ODBC View update sql server Posted by Frank Cazabon @ 6/19/2009 3:04:06 AM
RE: ODBC View update sql server Posted by Andy Kramek @ 6/19/2009 1:01:07 PM