Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too few parameters. Expected 6.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Could someone take a look at this code and possibly tell me what is wrong?<br><br>&lt;%<br>Dim DataConn<br>Dim SQL1<br>Dim MYSQL<br>PN = request.form(&quot;project_name&quot;)<br>UR = request.form(&quot;url&quot;)<br>CAT = request.form(&quot;category_id&quot;)<br>DUE = request.form(&quot;Due_Date&quot;)<br>Stat = request.form(&quot;status&quot;)<br>Note = request.form(&quot;notes&quot;)<br><br>Set DataConn = Server.CreateObject(&quot;ADODB.Connection&quot;)<br>Set SQL = Server.CreateObject(&quot;ADODB.Recordset&quot;)<br><br>DataConn.Open &quot;DBQ=&quot; & Server.Mappath(&quot;/Secure Employee DataBase/SecureEDB.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;<br><br>MYSQL = &quot;INSERT INTO Projects (Project, URL, Category, DueDate, Status, Notes) VALUES (PN,UR,CAT,DUE,Stat,Note)&quot;<br><br>SQL.Open MYSQL, DataConn&nbsp;&nbsp;&nbsp;<br>%&gt;<br><br>This is the Error Message I recieve when I run this.<br>-----------------------------------------------------------<br>Microsoft OLE DB Provider for ODBC Drivers error '80040e10' <br><br>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 6. <br><br>/Project.asp, line 44 <br>-----------------------------------------------------------<br><br>P.S.&gt; Why does it always report my error on a line (like line 44) that eithor doesn't exist or is a long way from where the actual code error occures, just wondering... <p>John Vogel<br><a href=mailto:johnvogel@computerwiz.net>johnvogel@computerwiz.net</a><br><a href= Home Page</a><br>Check out
 
This error usually means you spelled field names wrong. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Or this error means u have not filled up the compulsory feilds in ur Access database..try up with Nicks Soln..chk up ur fields name..or else change the compulsory fields..to non-compulsory.[i.e required-&gt;no]<br><br>Regards<br>Vinod<br>
 
Check the field names in your database<br>Check the variable name in your form page<br>Then check them all again.<br><br>I get this all the time 'coz I dont check things as I work through.<br><br>PMD
 
I am still not sure what the problem is, as I have tried all suggestions, looked at my table structure made sure there were no compulsory fields, checked, double checked then triple checked my fields, and nothing worked... so instead of using the UPDATE query I used the objRecordset.AddNew method, and it worked fine, so I don't have to worry about it now, just wondering what might have been the culprit. ASP, sheesh!<br> <p>John Vogel<br><a href=mailto:johnvogel@computerwiz.net>johnvogel@computerwiz.net</a><br><a href= Home Page</a><br>Jesus is the Way, the Truth, and the Life:<br>
Without the Way there is no going;<br>
Without the Truth there is no knowing;<br>
Without the Life there is no living. —Anon.
 
Dear John,<br><br>The first thing I see is that you are calling the ADODB.Recordset object's 'Open' method with a SQL 'INSERT' query. This is not appropriate since an INSERT query does not return a rowset. You should use the connection objects 'Execute' method to run executable SQL statements.<br><br>The next thing I see is the SQL statement, i.e.:<br><br>&gt;MYSQL = &quot;INSERT INTO Projects (Project, URL, Category, DueDate, Status, Notes) VALUES (PN,UR,CAT,DUE,Stat,Note)&quot;<br><br>Then you use it like this:<br><br>&gt;SQL.Open MYSQL, DataConn <br><br>The SQL statement is incorrect and will fail regardless of the application environment. You put your variables into the 'VALUES' clause of your SQL statement as though you expect them to be automatically expanded for you. Please notice that you just made a string value in a variable named 'MYSQL'. That string value is not going to be changed and is what is sent to the database engine. What you really need to have is something like this:<br><br>&quot;VALUES('&quot; + PN + &quot;',&quot; + UR + &quot;',&quot;.... etc, Text values are quoted and numeric values are not so if CAT is a number it would look like this:<br><br>&quot;VALUES('&quot; + PN + &quot;',&quot; + UR + &quot;',&quot; + CAT + &quot;,&quot;.... etc.<br><br>Whatever the value of of 'MYSQL' is at the time you call open, you should be able to take that text and put it in a MS Accesss Query window and run it. The text you assign to 'MYSQL' above will not run in MS Access, so therefore it will not run in ADO and certainly does not have anything to do <br><br>&gt;ASP, sheesh!<br><br>with ASP. <br><br>I normally check all SQL statements in either Oracle, SQL Server or MS Access native environments prior to trying to code them in a development environment (C++, Java, ASP) so that I know what the SQL statement needs to contain before I tackle application development.<br><br>Hope this helps<br>-pete
 
Those variables are not being written into the string. You are sending the NAMES of the variables to the driver rather than their VALUES. Also SQL uses single quotes around strings and no quotes around numeric values, date objects and booleans. Try concatenating the string like this:<br><br>MYSQL = "INSERT INTO Projects (Project, URL, Category, DueDate, Status, Notes) VALUES ('"&PN&"','"&UR&"',"&CAT&","&DUE&",'"&Stat&"','"&Note"&')"<br><br>so that what the driver sees is:<br><br>INSERT INTO Projects (Project, URL, Category, DueDate, Status, Notes) VALUES ('somevalue','somevalue',15,dateobject,'somevalue','somevalue')<br><br>Again which values have single quotes depends on what the database fields are set as (that can be confusing especially with date objects. I you need a script which creates a valid ODBC dateobject format email me). Also as Pete pointed out above, you don't need a recordset because you're not reading anything. Just open the connection like you have it, set up your string, then try:<br><br>DataConn.execute(MYSQL)<br><br>-Will Duty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top