Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. articles. downloads. faq. members. files. rss.
 From: Jim Booth
  Where is Jim Booth?
 Prospect
 Connecticut - United States
 Jim Booth
Subject: CursorAdapter question
Thread ID: 168538 Message ID: 168538 # Views: 12 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Friday, April 18, 2008 2:21:50 AM         
   



Ok here's the situation. I have a CursorAdapter class as below;

**************************************************
*-- Class: BooksAndAuthors
*-- Program: BooksAndAuthors.prg
*
* CursorAdapter to provide access to the Microsoft
* SQL Server data for books and authors
*

DEFINE CLASS booksandauthors AS cursoradapter
	SelectCmd = [SELECT TI.Title_id, TI.Title, AU.au_Lname, ] + ;
					[AU.au_Fname, TI.PubDate, ] + ;
					[TI.Price AS Price FROM pubs.dbo.Titles TI ] + ;
					[JOIN pubs.dbo.TitleAuthor TA ON TI.Title_id = TA.Title_id ] + ;
					[JOIN pubs.dbo.Authors AU ON TA.au_id = AU.au_id ] + ;
					[ORDER BY 1,2,3]
	Tables = [Titles]
	KeyFieldList = [title_id]
	UpdateNameList = "Title pubs.dbo.Titles.Title"
	UpdatableFieldList = [Title]
	Alias = "BooksAndAuthors"
	DataSourceType = "ODBC"
	CursorSchema = "Title_id C(6), Title C(120), Lname C(40), FName C(40), Pubdate T, Price Y"
	Name = "BooksAndAuthors"
	FetchAsNeeded = .T.
	AllowUpdate = .T.
	SendUpdates = .T.
	
	FUNCTION Init
		LOCAL lcConnection
		lcConnection = "driver=SQL Server; " + ;
		               ";server=NYCPSJWBOOTH\VINCENT; " + ;
		               "uid=***; pwd=***"
		This.DataSource = SQLSTRINGCONNECT(lcConnection)
	ENDFUNC

ENDDEFINE


I instantiate it with the following code;

SQLEXEC(ox.DataSource,"update pubs.dbo.titles set title = 'The Very Busy Executive''s Database Primer' where title_id = 'BU1032'")
ox.CursorFill()
BROWSE last


Now I am browsing the data. I make a change in the title field of one of the records and then move off of that record and execute;

?TABLEUPDATE(.t.,.t.,"BooksAndAuthors",laerror)


TableUpdate returns -1, the error array laerror has one element with the value of -1. What's wrong and why can't I get the cursoradapter to send the update to SQL Server?

JimB
www.JamesBooth.com
MVP 1993-2003
Microsoft Certified Professional in VFP

ENTIRE THREAD

CursorAdapter question Posted by Jim Booth @ 4/18/2008 2:21:50 AM
RE: CursorAdapter question Posted by Arjun Bagojikop @ 4/18/2008 5:46:58 AM
RE: CursorAdapter question Posted by Jim Booth @ 4/18/2008 4:00:59 PM
RE: CursorAdapter question Posted by Arjun Bagojikop @ 4/18/2008 7:38:10 PM
RE: CursorAdapter question Posted by Jim Booth @ 4/18/2008 8:39:55 PM
RE: CursorAdapter question Posted by Borislav Borissov @ 4/18/2008 9:12:36 PM
RE: CursorAdapter question Posted by Jim Booth @ 4/19/2008 6:05:23 AM
RE: CursorAdapter question Posted by Arjun Bagojikop @ 4/19/2008 6:33:40 AM
RE: CursorAdapter question Posted by Jim Booth @ 4/19/2008 7:52:46 AM
RE: CursorAdapter question Posted by Arjun Bagojikop @ 4/19/2008 6:29:39 AM
RE: CursorAdapter question Posted by Jim Booth @ 4/19/2008 6:34:26 AM
RE: CursorAdapter question Posted by Arjun Bagojikop @ 4/19/2008 6:39:38 AM
RE: CursorAdapter question Posted by Cetin Basoz @ 4/18/2008 9:42:42 PM