>************************************************** >*-- 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 >>
>ox = NEWOBJECT("BooksAndAuthors","c:\effective\application\prgs\booksandauthors.prg") >ox.CursorFill() >BROWSE last >>
>?TABLEUPDATE(.t.,.t.,"BooksAndAuthors",laerror) >>
UpdateNameList = "Title pubs.dbo.Titles.Title, title_id pubs.dbo.Titles.title_id"