Results 1 to 4 of 4

Thread: Help! Too few parameters. Expected 2.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Help! Too few parameters. Expected 2.

    Ok I am doing an SQL insert and I get Too few parameters. Expected 2.

    This used to work but another engineer got his hands on the database and changed field names and join types now
    I get this error.
    I changed all code in my asp page to reflect the field names and I even broke down the sql insert to one field and
    it still errors in it. Below is my code.
    I also removed all joins in the table so it is a simple insert and still I get the error...

    Code:
     
    <!--#include file="Connect.asp" -->
    
    <%
    Dim Emp1
    Dim Proj
    Dim qLevel
    Dim pDate
    Dim nDef
    Dim tTime
    
    
    		Emp1 = CStr(Request("Emp"))
    		Proj = CStr(Request("ProjName"))
    		qLevel =Cstr(Request("LTest"))
    		pDate = CStr(Request("InDate"))
    		nDef = Cstr(Request("NumDefects"))
    		tTime = cstr(Request("TestTime"))
    		
    		'Response.Write(Emp1)& "<br>"
    		'Response.Write(Proj)& "<br>"
    		'Response.Write(qLevel)& "<br>"
    		'Response.Write(pDate)& "<br>"
    		'Response.Write(tTime) & "<br>"
    		'Response.Write(nDef)& "<br>"
    Function f(N)
    	ret = Request.Form(N)
    	ret = Replace(ret, "<", "&lt;")
    	ret = Replace(ret, ">", "&gt;")
    	ret = Trim(ret)
    	ret = Replace(ret, "'", "''")
    	
    	If Len(ret) > 255 Then
    		ret = Left(ret, 255)
    	End If
    	
    	f = ret
    	
    End Function
    'Con.Execute("INSERT INTO TAGDB (TAG_NAME, TAG_TEXT, TAG_TIME) VALUES('" & f("Name") & "','" & mkicons(f("Text")) & "','" & Now & "')")
    conn.execute("INSERT INTO TrackerQuery(Employee, Project_Name, eDate, TestLevel, Hours, Number_of_Defects_Found)VALUES ('" & Emp1 & "','" & Proj & "','" & pDate & "','" & TTime & "','" & NDef & "','" & qLevel & "')")	
    'conn.execute("INSERT INTO TrackerQuery(Project_Name)VALUES ('" & Proj & "')")		
    %>
    <HTML>
    <head> 
    <title>Data Submitted</title>
    </head>
    <body>
    <h1 align="center">Thank You For Your Data</h1>
    <h2 align="center">You will redirected back to TimeTrackers main page</h2><br><br>
    <a href="http://ssd-web/ssd-dashboard2/index.html">NSS Home Page</a>
    <meta HTTP-EQUIV=REFRESH Content = "3;url=http://ssd-web/ssd-dashboard2/timetracker/ttmain.asp">
    </body>
    </html>
    TMacPherson
    MIS Systems Engineer
    [email protected]


  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    The error message indicates that you are using field name/s that dont exist in the database.

    Try this

    Put this code after the end of Function f()
    VB Code:
    1. dim sql
    2. sql="INSERT INTO TrackerQuery(Employee, Project_Name, eDate, TestLevel, Hours, Number_of_Defects_Found)VALUES ('" & Emp1 & "','" & Proj & "','" & pDate & "','" & TTime & "','" & NDef & "','" & qLevel & "')"
    3.  
    4. response.write sql
    5. response.end
    copy the outputed sql and run it in your database(not sure what database are you using) directly. See if that runs, i suspect it wont, and your db should tell you which field name is incorrect. Hope this helps.

    Danial
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Thanks

    Thank Danial you have put me on the right path! Now I can see what fields are not being submitted.

    -Troy
    TMacPherson
    MIS Systems Engineer
    [email protected]


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    R

    Danial I am using Access how would I run this Query in Access? Unlike SQL there is no Access Query Analyzer that I know of.
    TMacPherson
    MIS Systems Engineer
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width