Append / delete

Topics: User Forum
Dec 22, 2010 at 9:19 PM

Hi,

I am starting with ActiveVFP and i am looking for method how to append/delete new record using web form. I tried to find some example in demo page but there is missing append functionality.

Thanks a lot for any hint.

Jaroslav

Coordinator
Dec 22, 2010 at 10:14 PM

Should be the same as normal Foxpro:

INSERT INTO mcookies (KEY, USER, PASS) VALUES (lcNewKey, lcName, lcPassWord)

OR

APPEND BLANK
    REPL PID WITH lcPID
    REPL TRANS WITH lnTrans

Jan 18, 2011 at 1:18 PM

Hi, I have also been attempting to do this for a couple of weeks now.  I am having difficulty  passing a web form input value to the VFP script within the html.  Could you give a small code example? Thanks for any help.

Coordinator
Jan 18, 2011 at 1:46 PM

 

From the included example at http://thetechconsult.com/test/default.aspx?action=vfpscript :
main.prg
CASE oProp.Action=='vfpscript'
    lcHTMLfile = 'vfpscript.htm'
    lcHTMLout= FILETOSTR(oProp.HtmlPath+lcHTMLfile)
    lcHTMLout= oHTML.mergescript(lcHTMLout) && app logic is in HTML vfp script

HTML

<% lcCompany = UPPER(NVL(oRequest.Form("txtCompany"),[])) lcWhere = "" IF !EMPTY(lcCompany) lcWhere = "WHERE UPPER(company) = lcCompany" ENDIF SELECT * FROM customer &lcWhere ; INTO Cursor tCursor ; ORDER BY Company lnReccount = RECCOUNT() %> <form method="POST" action="<%=oProp.ScriptPath+[?action=vfpscript]%>"> <font face="Arial">Company:</font> <input type="text" name="txtCompany" value="<%= lcCompany %>" size="20"> <input type="Submit" value=" Get Customers">&nbsp;<input type="button" value="Reset" name="B1" onclick="window.location='<%=oProp.ScriptPath+[?action=vfpscript]%>';"> <input type="button" value="Go Back" onClick="window.location = '<%=oProp.ScriptPath%>';"> </form>

 

 

Jan 18, 2011 at 10:46 PM

Thanks, that is the example I have been working with.  When I put the VFP commands above the form section as it is listed in the example, the form disappears. 

When below the form section, I see the form however the script does not execute on clicking the submit button. 

Coordinator
Jan 18, 2011 at 11:41 PM
Edited Jan 18, 2011 at 11:42 PM

Get it as close to the example that works as possible.  The example code works on your machine, right??

There's something in your code that's just wrong (could be something simple).  More than likely your code is just missing something. 

Jan 19, 2011 at 2:53 AM

Yes, the examples work great, and I have been able to make VFP functions work, as well as display table data and such.   Overall, to get ActiveVFP installed and running

was fairly simple and I am a newbie when it comes to web apps.  I will continue to hunt for the solution. Thank you for your help.

Jan 19, 2011 at 8:47 PM

Hi,

here is my code:

main.prg

CASE oProp.Action=='new'
  LOCAL lchtmlfile,lchtmlout,lcCustID

  oSession.VALUE("cust_id",'0')
  oSession.VALUE("name",'')
  oSession.VALUE("city",'')

  lchtmlfile = 'detail1.htm'
  lchtmlout=FILETOSTR(oProp.HtmlPath+lchtmlfile)
  lchtmlout= oHTML.mergetext(lchtmlout)

CASE oProp.Action=="thanks1"
  LOCAL lchtmlfile,lchtmlout,memidx,memmch
  IF .NOT. USED('customers')
    USE ('customers') IN 0 SHARED
  ENDIF
  SELECT customers
  SET ORDER TO masterindex
  GO bottom
  memidx=customers.cust_id+1
  IF memidx>0
  ELSE
    memidx=1
  ENDIF
 
  INSERT INTO customers (cust_id,name,city) ;
    VALUES (memidx,oRequest.FORM("name"),oRequest.FORM("city"))

  lchtmlfile = 'thanks.htm'
  lchtmlout=FILETOSTR(oProp.HtmlPath+lchtmlfile)
  lchtmlout= oHTML.mergetext(lchtmlout)




HTML

<input type="button" value="New" onClick="window.location = '<%=oProp.ScriptPath+[?action=new]%>';">


<form action="<%=oProp.ScriptPath+[?action=thanks1]%>" method="post" name="theForm" onsubmit="return Form1_Validator(this)">


Jan 29, 2011 at 7:25 PM

Looks as if my trouble is tied to a read only error.  "Cannot update the cursor  since it is read-only".  I have no trouble appending/replacing records in a temporary cursor

however when trying the same with a table, I get the read only error.  Any suggestions?  Thanks.

Coordinator
Jan 29, 2011 at 9:53 PM

What version of Windows are you on?  I used to have this problem once in a while on my old server. For that,  I just restarted the server and it worked again.  If it doesn't, make sure the table isn't really read-only.