Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CursorAdapter Updating
Message
From
18/04/2008 14:43:47
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01311736
Message ID:
01311759
Views:
24
Jim,

Can you pick up the ODBC error if you pass 2 to TABLEUPDATE() as the first parameter rather than .T.?

The one thing that I noticed is that you have the fully qualified table name in the UpdateNameList but have just the unqualified table name in the Tables property. I wonder if this creates an internal resolution issue of some sort when the update sql is generated.

It seems to me that when working with cursor adapters, it's usually worth th effort to put a debug and suspend in the after(insert or update) method and look at the actual sql that has been generated. I can usually get a good AERROR() return from the command line when the program execution is suspended immediately after the error.


Hope this helps


Jim Fisher


>I have the following CursorAdapter defined.
>
>
>**************************************************
>*-- 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 can query the data with the following;
>
>
>ox = NEWOBJECT("BooksAndAuthors","c:\effective\application\prgs\booksandauthors.prg")
>ox.CursorFill()
>BROWSE last
>
>
>And I see the browse window and can edit the title field on the first record. I move off of the first record without any error and then I execute;
>
>
>?TABLEUPDATE(.t.,.t.,"BooksAndAuthors",laerror)
>
>
>And tableupdate returns -1, the array has one element with the value of -1 and an AERROR() show no error occurred.
>
>Any ideas why this CA won't do an update?
Previous
Reply
Map
View

Click here to load this message in the networking platform