Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update a record
Message
From
24/10/2002 03:52:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
23/10/2002 17:27:34
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00714575
Message ID:
00714700
Views:
22
>Hi everyone,
>
>I'm getting into a bit of a fix! I have a single field which I want to be able to update on a table. The table (database),has been changed from a local to a remote one, and allows for more then one person to access / update the record at a time.
>
>The ONLY field that I need to allow people to update is the Email one. This is done via a textbox on the form.
>
>The table is called 'contacts' and the field is called 'email'. All I want to do is lock the record, update it and that's it!. In the Data Environment I have set the Buffer to '5', but when I run the code below it comes up with an error message 'Function requires row or table buffering mode'. I am new to FoxPro, so if some kind person could help me I would appreciate it. I'm using FoxPro7, The table is called 'contacts', the field is called 'email'. The code I have used is:
>
>LOCAL lemail, lGoOn
>
>SET MULTILOCKS ON
>
>lemail=this.Parent.txtEmail.Value *This is the new email input
>CURSORSETPROP("Buffering",5,"contacts")
>BEGIN TRANSACTION
>lGoOn=.T.
>
>UPDATE contacts set contacts.email=(lemail);
>where contacts.managercode=(Ipmcode)
>
>IF NOT TABLEUPDATE()
> lGoOn =.F.
>ENDIF
>
>IF lGoOn
> END TRANSACTION
>ELSE
> ROLLBACK
> =TABLEREVERT()
>ENDIF
>
>I was fine when I was updating a local table, but it just will not work on a LAN. I am new to FoxPro, and just can't understand what I'm doing wrong. Thanks in advance
>
>Rob

Rob,
TableUpdate(), TableRevert() require buffering and they both would operate on current work area unless you provide it in their parameters. Looks like when you try to run this current selected table is not 'contacts'.
Most of the functions in VFP has alias parameter. Try to use it or at least be sure you're on correct work area (ie:select myAlias).
Note that I included built-in alias m. for memory variables to prevent name clashes with table fields (when used on right side table field names take precedence over memory variable names unless prefixed with m.).
LOCAL lemail
SET MULTILOCKS ON && This should already be on ?

lemail=this.Parent.txtEmail.Value *This is the new email input
CURSORSETPROP("Buffering",5,"contacts") && Not set in DE ?

BEGIN TRANSACTION
UPDATE contacts set email = m.lemail ;
  where managercode = m.Ipmcode
IF !TABLEUPDATE(2,.t.,'contacts')
 rollback
 tablerevert(.t.,'contacts')
else
 end transaction
ENDIF
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform