landslide
12-12-2006, 07:43 PM
see below
Last edited by landslide : Today at 05:18 PM.
Last edited by landslide : Today at 05:18 PM.
|
Click to See Complete Forum and Search --> : [RESOLVED] update problem landslide 12-12-2006, 07:43 PM see below Last edited by landslide : Today at 05:18 PM. russell 12-12-2006, 09:46 PM looks like Request.QueryString("comments") is undefined. did u pass a query string? landslide 12-13-2006, 11:19 AM The error is telling me that Jan is undefined. Im really new at this any idea how to fix this. russell 12-13-2006, 12:16 PM you modified your original post! ok the error is telling u that Request.QueryString("Jan1") is empty. As I asked b4, is there a querystring value in the URL? it would look like this: http://yourSite.com/systems/lvcc/janapprovalfiles/jan1approve.asp?Jan1=someValueHere&comments=someValue&seid=someValue landslide 12-13-2006, 12:27 PM sorry no it is not in the URL of the page. russell 12-13-2006, 12:49 PM try putting it in the url landslide 12-13-2006, 07:34 PM I not quite sure how to do that. All I am trying to do is when this page loads. has a random number of accsess database records. I am trying to update all the records at once. There are only three field In my database to update. SEID=my uniique field, Jan1 and extra2. I am using dreamweaver and I tried the following SQL UPDATE tblJanuary SET tblJanuary.Jan1 = 'param_jan1' , tblJanuary.Extra2 = 'param_comment' WHERE tblJanuary.seid IN (param_seid) Here are the varables I set var#1name=param_seid Run time value=Request.QueryString("seid") var#2name=param_jan1 Run time value=Request.QueryString("Jan1") var#3name=param_comment Run time value=Request.QueryString("Extra2") I keep getting the same error. Microsoft JScript runtime error '800a1391' 'update__param_jan1' is undefined /systems/lvcc/janapprovalfiles/jan1approve.asp, line 26 what am i doing wrong? please help. thanks again for your help. russell 12-13-2006, 11:51 PM try like this. then u need a link or a form to put the values in the querystring. or u can manually type it in to test. in a url, everything after the ? is the querystring. so, mysite.com/page.asp?a=1 i can get the value "1" by testing Request.QueryString("a") <% if((Request.QueryString("seid").length>0) && (Request.QueryString("Jan1").length >0) && (Request.QueryString("Extra2").length > 0)) { var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_lvcc_STRING; Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.Jan1, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.Jan1 LIKE ('R%') ORDER BY tblJanuary.EOD"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); var Recordset1_numRows = 0; var update = Server.CreateObject("ADODB.Command"); update.ActiveConnection = MM_lvcc_STRING; update.CommandText = "UPDATE tblJanuary SET tblJanuary.Jan1 = '"+ update__param_Jan1.replace(/'/g, "''") + "', tblJanuary.Extra2 = '"+ update__param_comments.replace(/'/g, "''") + "' WHERE tblJanuary.seid IN ("+ update__param_seid.replace(/'/g, "''") + ") "; update.CommandType = 1; update.CommandTimeout = 0;update.Prepared = true; update.Execute(); } else { Response.Write("No QueryString values"); } %> landslide 12-14-2006, 11:27 AM see below russell 12-14-2006, 11:39 AM change the method of form to "get" or change all Request.QueryString to Request.Form landslide 12-14-2006, 12:09 PM I changed the method to "get" but i get the same info when it loads in the browser. At the top of the browser it says No QueryString values on the next line 1 have my calculate button which works fine. Then I have my table with the form boxes in it. This also dispays correctly. Then I have my submit button. When I click on the submit button nothing happens. I hope this is enough information. Please let me know if you need anything else. russell 12-14-2006, 12:13 PM i just noticed that you are returning false on the submit of the form. u have to allow form to be submitted ( return true ). what does doCalcs() do? landslide 12-14-2006, 12:16 PM it is one you helped me with on 12-12. At the top I have a box I put a number in and it changes the R value to an A and counts to 0 once at zero it replaces the R with a D. I changed it to true and it changes the values quickly and submits at the same time and it works :). Is there a way to have it calulate but not submit the form. I want the user to review the changes before submiting. The other thing I notice it is doing is it is acting like it is submited but none of the values in my database have changed. Any ideas. russell 12-14-2006, 01:16 PM Is there a way to have it calulate but not submit the formcan have function return true or false depending on if the calculate function has been executed yet. for example var blnReview = false; function doCalcs() { // do whatever u do here // then blnReview = !blnReview; return !blnReview; } and u change the form to say onsubmit = "return doCalcs()" this way, the form won't be submitted first time button is pressed, but will be 2nd time. can modify function to update the button value too -- say it says "Review" by default, but after clicked it says ""Submit"... russell 12-14-2006, 01:20 PM The other thing I notice it is doing is it is acting like it is submited but none of the values in my database have changed. just b4 update.Execute(); do this Response.Write(update.CommandText); what does it display? landslide 12-14-2006, 02:51 PM Ok I made the changes. One thing I did changed is the calculation is now done on blur which works perfect. I placed in the code you told me to. When I hit submit the only thing that happens is the values return to the originals when the page is displayed and the url changes to this [url]http://xxxx.xxxxxxx.xxx.xxx/xxx/janapprovalfiles/jan1approve.asp?lvavalbl=1&seid=1TZHB&Jan1=A&Comments=&Submit2=Submit I have attached my new code and highlighted the changes. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <!--#include file="../../../Connections/lvcc.asp" --> <% var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_lvcc_STRING; Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.Jan1, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.Jan1 LIKE ('R%') ORDER BY tblJanuary.EOD"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); var Recordset1_numRows = 0; %> <% var Repeat1__numRows = -1; var Repeat1__index = 0; Recordset1_numRows += Repeat1__numRows; %> <% if((Request.QueryString("seid").length>0) && (Request.QueryString("Jan1").length >0) && (Request.QueryString("Extra2").length > 0)) { var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_lvcc_STRING; Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.Jan1, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.Jan1 LIKE ('R%') ORDER BY tblJanuary.EOD"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); var Recordset1_numRows = 0; var update = Server.CreateObject("ADODB.Command"); update.ActiveConnection = MM_lvcc_STRING; update.CommandText = "UPDATE tblJanuary SET tblJanuary.Jan1 = '"+ update__param_Jan1.replace(/'/g, "''") + "', tblJanuary.Extra2 = '"+ update__param_comments.replace(/'/g, "''") + "' WHERE tblJanuary.seid IN ("+ update__param_seid.replace(/'/g, "''") + ") "; update.CommandType = 1; update.CommandTimeout = 0;update.Prepared = true; Response.Write(update.CommandText); update.Execute(); } else { Response.Write("No QueryString values"); } %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> var blnReview = false; function doCalcs(form1){ count = form1.lvavalbl.value; for(x=0; x<document.getElementsByName('jan1').length; x++){ document.getElementsByName('jan1')[x].value = (count > 0) ? 'A' : 'D' count --; blnReview = !blnReview; return !blnReview; } } </script></head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Jan1</title> <style type="text/css"> <!-- .style3 {font-size: 9px} --> </style> </head> <body> <form method="get" name="form1" id="form1"> <p>Input the amount of leave that can be given <input name="lvavalbl" type="text" id="lvavalbl" size="2" onblur="doCalcs(this.form)"/> </p> <table border="1" cellpadding="0" cellspacing="0"> <tr> <td width="76"><div align="center" class="style3">SSN</div></td> <td width="77"><div align="center" class="style3">EOD</div></td> <td width="71"><div align="center" class="style3">SCD</div></td> <td width="20"><div align="center" class="style3">Last Four</div></td> <td width="97"><div align="center" class="style3">Firstname</div></td> <td width="95"><div align="center" class="style3">Lastname</div></td> <td width="105"><div align="center" class="style3">ORGCODE</div></td> <td width="79"><div align="center" class="style3">SEID</div></td> <td width="24"><div align="center" class="style3">Jan1</div></td> <td width="60"><div align="center" class="style3">Comments</div></td> <td width="113"><div align="center" class="style3">Timestamp1</div></td> </tr> <% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %> <tr> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("SSN").Value)%></div></td> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("EOD").Value)%></div></td> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("SCD").Value)%></div></td> <td><span class="style3"><%=(Recordset1.Fields.Item("Last Four").Value)%></span></td> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("Firstname").Value)%></div></td> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("Lastname").Value)%></div></td> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("ORGCODE").Value)%></div></td> <td><div align="center" class="style3"> <input name="seid" type="text" id="seid" value="<%=(Recordset1.Fields.Item("SEID").Value)%>" size="5" maxlength="5" /> </div></td> <td><div align="center" class="style3"> <input name="Jan1" type="text" id="Jan1" value="<%=(Recordset1.Fields.Item("Jan1").Value)%>" size="4" /> </div></td> <td><div align="center" class="style3"> <input name="Comments" type="text" id="Comments" value="<%=((Recordset1.Fields.Item("extra2").Value))%>" size="10" /> </div></td> <td><div align="center" class="style3"><%=(Recordset1.Fields.Item("Timestamp1").Value)%></div></td> </tr> <% Repeat1__index++; Recordset1.MoveNext(); } %> </table> <p> <input type="submit" name="Submit2" value="Submit" /> </p> Only one button now. </form> </body> </html> <% Recordset1.Close(); %> landslide 12-15-2006, 01:17 PM Anyone have any Idea why this is not sending the information? russell 12-15-2006, 01:35 PM did u do this (http://www.webdeveloper.com/forum/showpost.php?p=681880&postcount=15) ? what did it display? landslide 12-15-2006, 02:18 PM Yes I did the following var update = Server.CreateObject("ADODB.Command"); update.ActiveConnection = MM_lvcc_STRING; update.CommandText = "UPDATE tblJanuary SET tblJanuary.Jan1 = '"+ update__param_Jan1.replace(/'/g, "''") + "', tblJanuary.Extra2 = '"+ update__param_comments.replace(/'/g, "''") + "' WHERE tblJanuary.seid IN ("+ update__param_seid.replace(/'/g, "''") + ") "; update.CommandType = 1; update.CommandTimeout = 0;update.Prepared = true; do this Response.Write(update.CommandText); update.Execute(); } else { Response.Write("No Quesry String"); } %> and then on the form line I have <form method="get" name="form1" id="form1" onSubmit="return true"> It is giving me the following error. Microsoft JScript compilation error '800a0400' Expected 'while' /systems/lvcc/janapprovalfiles/jan1approve.asp, line 35 Response.Write(update.this); russell 12-16-2006, 03:02 PM take "do this" out of the code. i was saying: just before this line update.Execute(); do this: Response.Write(update.CommandText); "do this" meant "Add This Line" :) :) :) landslide 12-17-2006, 12:59 AM I tried this I do not get any errors but it still does not save the information in my database. Could it be what is on my form on submit line? russell 12-17-2006, 02:47 PM what did Response.Write(update.CommandText); display?????? can't troubleshoot without seeing the query being executed landslide 12-18-2006, 11:47 AM When I press submit the field resets to a R and this is displayed in the URL: http://xxxx.xrxxe.xxx.xxx/systems/lvcc/janapprovalfiles/jan1approve.asp?lvavalbl=1&seid=M79DB&Jan1=A&Comments=&Submit=Submit. Besides that nothing else. russell 12-18-2006, 01:11 PM Change this Response.Write(update.CommandText); to this Response.Write("<h4>Query: "); Response.Write(update.CommandText); Response.Write("</h4>"); Response.End now does it display anything? all we're interested in is figuring out what is wrong with the query. ,may be parameters, may be something else. cant know whats wrong until figure out what the query being executed is russell 12-18-2006, 01:12 PM also, take a look at the url u just posted. comments= <empty!!!!> landslide 12-18-2006, 01:42 PM I pasted the code and it does the same thing. this is what is displayed in the URL. http://xxx.xxxxx.ixx.xxx/systems/lvcc/janapprovalfiles/jan1approve.asp?lvavalbl=1&seid=M79DB&Jan1=A&Comments=test&Submit=Submit. The last time the comments box was empty I made sure to put something in it this time. This is what my code looks like now. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <!--#include file="../../../Connections/lvcc.asp" --> <% var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_lvcc_STRING; Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.Jan1, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.Jan1 LIKE ('R%') ORDER BY tblJanuary.EOD"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); var Recordset1_numRows = 0; %> <% var Repeat1__numRows = -1; var Repeat1__index = 0; Recordset1_numRows += Repeat1__numRows; %> <% if((Request.QueryString("seid").length>0) && (Request.QueryString("Jan1").length >0) && (Request.QueryString("Extra2").length > 0)) { var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_lvcc_STRING; Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.Jan1, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.Jan1 LIKE ('R%') ORDER BY tblJanuary.EOD"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); var Recordset1_numRows = 0; var update = Server.CreateObject("ADODB.Command"); update.ActiveConnection = MM_lvcc_STRING; update.CommandText = "UPDATE tblJanuary SET tblJanuary.Jan1 = '"+ update__param_Jan1.replace(/'/g, "''") + "', tblJanuary.Extra2 = '"+ update__param_comments.replace(/'/g, "''") + "' WHERE tblJanuary.seid IN ("+ update__param_seid.replace(/'/g, "''") + ") "; update.CommandType = 1; update.CommandTimeout = 0;update.Prepared = true; Response.Write("<h4>Query: "); Response.Write(update.CommandText); Response.Write("</h4>"); Response.End update.Execute(); } else { Response.Write(""); } %> russell 12-18-2006, 01:52 PM what did it display in the BROWSER? landslide 12-18-2006, 02:22 PM At the top the title was Jan1 - Microsoft Inernet explorer. The URL changed to: httpxxxx.xxxx.xx.xx/systems/lvcc/janapprovalfiles/jan1approve.asp?lvavalbl=1&seid=M79DB&Jan1=A&Comments=test&Submit=Submit And after I hit Submit the field changed back to the original that is it nothing else. Is there something it should display? My deamweaver is also saying that I have 2 recordset1 under applications. russell 12-18-2006, 03:35 PM in your browser window, where content is normally displayed, it should say query: and hopefully, something like UPDATE tblJanuary SET tblJanuary.Jan1... landslide 12-18-2006, 05:38 PM I modified my code a little bit and now it displays this. Query: UPDATE tblJanuary SET tblJanuary.Jan1 = 'param_Jan1' WHERE tblJanuary.SEID IN (param_SEID) I hope that helps. russell 12-18-2006, 09:01 PM if you comment out the debug code (the stuff i gave u to write that out) it oughtta update the db now. is 'param_Jan1' the intended value?from the url u showed, it looks like it should be 'A'. i dont see where u are setting the value of update__param_Jan1. landslide 12-19-2006, 11:43 AM I dont think I have set it up. That is probably why it keeps telling me that it is Jan1 undefined. How would I write that. This is what I have so Far. Thanks again for your help sorry im a tart when it comes to this. <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <!--#include file="../../../Connections/lvcc.asp" --> <% var Recordset1 = Server.CreateObject("ADODB.Recordset"); Recordset1.ActiveConnection = MM_lvcc_STRING; Recordset1.Source = "SELECT tblJanuary.SSN, tblJanuary.EOD, [tblJanuary.Last four], tblJanuary.firstname, tblJanuary.lastname, tblJanuary.ORGCODE, tblTollFreeEmployees.SCD, tblJanuary.SEID, tblJanuary.Jan1, tblJanuary.extra2, tblJanuary.timestamp1 FROM tblJanuary, tblTollFreeEmployees WHERE [tblTollFreeEmployees.SEID] = [tblJanuary.SEID] and tblJanuary.Jan1 LIKE ('R%') ORDER BY tblJanuary.EOD"; Recordset1.CursorType = 0; Recordset1.CursorLocation = 2; Recordset1.LockType = 1; Recordset1.Open(); %> <% var Repeat1__numRows = -1; var Repeat1__index = 0; Recordset1_numRows += Repeat1__numRows; %> <%var Recordset1_numRows = 0; if((Request.QueryString("seid").length>0) && (Request.QueryString("Jan1").length >0) && (Request.QueryString("Extra2").length > 0)) { var update = Server.CreateObject("ADODB.Command"); update.ActiveConnection = MM_lvcc_STRING; update.CommandText = "UPDATE tblJanuary SET tblJanuary.Jan1 = 'param_Jan1', tblJanuary.Extra2 = 'param_comments' WHERE tblJanuary.seid IN (param_seid) "; update.CommandType = 1; update.CommandTimeout = 0; update.Prepared = true; update.Execute(); } else { Response.Write("No QueryString values"); } %> russell 12-19-2006, 12:30 PM landslide, u keep posting different code! alright, in this one... change the last script block -- that is everything between <%var Recordset1_numRows = 0; and %> to what I put below. change it exactly and dont make any other changes <% var Recordset1_numRows = 0; var param_Jan1 = Request.QueryString("Jan1"); var param_comments = Request.QueryString("comments"); var param_seid = Request.QueryString("seid"); if((param_seid.length>0) && (param_Jan1.length >0) && (param_comments.length > 0)) { var update = Server.CreateObject("ADODB.Command"); update.ActiveConnection = MM_lvcc_STRING; update.CommandText = "UPDATE tblJanuary SET Jan1 = '" + param_Jan1.replace(/'/g, "''") + "', Extra2 = '" + param_comments.replace(/'/g, "''") + "' WHERE seid IN (" + param_seid.replace(/'/g, "''") + ")"; update.CommandType = 1; update.CommandTimeout = 0; update.Prepared = true; update.Execute(); } else { Response.Write("No QueryString values"); } %> also, please put your code samples between code tags -- it makes it much easier to read. I would suggest chcking out an ASP tutorial for basic stuff like accessing the Request Object, assigning variables etc. You will find a lot more samples of ASP written is vbScript than JScript, but either way is ok. this (http://www.w3schools.com/asp/default.asp) is a pretty decent place to start. and there are many others. landslide 12-19-2006, 12:38 PM Thanks for evreything. Sorry Just practicing on my code. russell 12-19-2006, 12:45 PM no problem. so u got it working? landslide 12-19-2006, 07:59 PM yes thanks again. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |