colzboppo
09-16-02, 12:35
| Good day, I have a problem... It is an INSERT new record page, that does this into a text file... It has worked before - so I know it's possible... Can anyone spot the mistake? Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) [Microsoft][ODBC Text Driver] Too few parameters. Expected 5. /sales/_admin/new.asp, line 59 And it is on this page... <%@Language="VBscript"%> <% 'Gets the last record if page has just been loaded if Cstr(request.form("submittion")) <> "true" then sDSNFile = "csv.dsn" sPath = "D:\Webs\t-shirtprinter.com\data\" ' Time to construct our dynamic DSN sDSN = "FileDSN=" & sPath & sDSNFile & _ ";DefaultDir=" & sPath & _ ";DBQ=" & sPath & ";" ' Building Data Connection Dim Conn, rs Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open sDSN Dim sql sql = "SELECT * FROM stock.txt" set rs = conn.execute(sql) 'stores to an array rsGR = rs.getrows() 'closes conn rs.close set rs = nothing 'Gets last Record ID LastR = UBound(rsGR,2) firstCol = LBound(rsGR,1) lastID = rsGR(firstCol,LastR) 'formats last ID lastID = lastID + 1 response.write lastID 'Else as in form has been posted Else sPath = "D:\Webs\t-shirtprinter.com\data\" ' Time to construct our dynamic DSN sDSNFile = "csv.dsn" sDSN = "FileDSN=" & sPath & sDSNFile & _ ";DefaultDir=" & sPath & _ ";DBQ=" & sPath & ";" editTable = "stock.txt" fields = "ID,colour,garment,style,quality,size,quantity" Values = request.form("ID") & "," & request.form("colour") & "," & request.form("garment") & "," & request.form("style") & "," & request.form("quality") & "," & request.form("size") & "," & request.form("quantity") editConnection = sDSN editQuery = "INSERT into " & editTable & " (" & fields & ") values (" & Values & ")" response.write editQuery ' execute the insert Set editCmd = Server.CreateObject("ADODB.Command") editCmd.ActiveConnection = editConnection editCmd.CommandText = editQuery editCmd.Execute editCmd.ActiveConnection.Close response.redirect("default.asp") End If %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- #BeginTemplate "/Templates/Default.dwt" --> <head> <!-- #BeginEditable "doctitle" --> <title>New stock record</title> <!-- #EndEditable --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="../../default.css" type="text/css"> <script language="JavaScript"> <!-- function MM_findObj(n, d) { //v4.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> </head> <body bgcolor="#FFFFFF" text="#000000"> <h1><!-- #BeginEditable "Title" -->New Stock record<!-- #EndEditable --></h1> <table width="100%" border="0" cellpadding="6" cellspacing="0" name="body"> <tr> <td><!-- #BeginEditable "body" --> <h6>Please fill all the details in</h6> <form name="form1" method="post" action="" onSubmit="MM_validateForm('colour','','R','style','','R','qu antity','','RisNum');return document.MM_returnValue"> <table width="150" border="0" cellpadding="4" cellspacing="0"> <tr> <td> <p>Colour</p> </td> <td> <input type="text" name="colour" size="20"> </td> </tr> <tr> <td>Size</td> <td> <select name="size"> <option value="XXL" selected>XXL</option> <option value="XL">XL</option> <option value="L">L</option> <option value="M">M</option> <option value="S">S</option> </select> </td> </tr> <tr> <td>Quality</td> <td> <select name="quality"> <option value="perfect" selected>Perfect</option> <option value="irregular">Seconds</option> </select> </td> </tr> <tr> <td>Garment</td> <td> <select name="garment"> <option value="t-shirt">T-shirt</option> <option value="sweatshirt">Sweatshirt</option> <option value="skinny">Womens skinny fit top</option> </select> </td> </tr> <tr> <td>Style</td> <td> <input type="text" name="style" size="20"> </td> </tr> <tr> <td>Quantity</td> <td> <input type="text" name="quantity" size="20"> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"> <input type="hidden" name="submittion" value="true"> <input type="hidden" name="ID" value="<%=lastID%>"> </td> </tr> </table> </form> <p> </p> <!-- #EndEditable --></td> </tr> <tr> <td class="Links"><a href="http://www.t-shirtprinter.com">home</a> | <a href="../../services">services</a> | <a href="../../sales">sales</a> | <a href="../../links">links</a> | <a href="../../contact.htm">contact</a></td> </tr> </table> </body> <!-- #EndTemplate --> </html> |