Too few parameters error

Results 1 to 4 of 4

Thread: Too few parameters error

  1. #1
    Join Date
    Dec 1969

    Default Too few parameters error

    I am new to ASP and I can&#039t figure out why this won&#039t work. I am trying to query a database, but I keep getting this error:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e10&#039 <BR><BR>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. <BR><BR>/asp/searchnameaddressscript.asp, line 25 <BR><BR>Line 25 below looks like this below:<BR>objRS.Open strSQL, objConn<BR><BR><BR>Here is the full code. ANY IDEA WHAT&#039S WRONG???<BR><BR><BR>&#060;%@ Language=VBScript %&#062;<BR>&#060;% Option Explicit %&#062;<BR>&#060;!--#include virtual="/"--&#062;<BR>&#060;%<BR> &#039Open up a connection to our Access database that stores the customer<BR> &#039information. We will use a DSN-less connection here.<BR> Dim objConn<BR> Set objConn = Server.CreateObject("ADODB.Connection")<BR> objConn.ConnectionString = "DSN=NamesandAddresses.dsn"<BR> objConn.Open<BR><BR><BR> &#039Read in the characters the user entered<BR> Dim strName<BR> strName = Trim(Request("Name"))<BR><BR> &#039Create our SQL statement variable<BR> Dim strSQL<BR> strSQL = "SELECT FirstName, LastName, Email, HomePhone FROM NamesandAddresses WHERE Name LIKE &#039" & strName & "%&#039" & _<BR> " ORDER BY LastName"<BR><BR> &#039Create a recordset object instance, and execute the SQL statement <BR> Dim objRS<BR> Set objRS = Server.CreateObject("ADODB.Recordset")<BR> objRS.Open strSQL, objConn<BR><BR><BR> If objRS.EOF then<BR> &#039No records were returned for the characters entered by the user<BR> Response.Write "There are no products that begin with " & _<BR> UCase(strName)<BR> Else<BR> &#039There are one or more products that meet the condition entered by<BR> &#039the user. Display these products...<BR> Response.Write "&#060;B&#062;A Listing of Products beginning with " & _<BR> UCase(strName) & ":&#060;/B&#062;<BR>"<BR> Do While Not objRS.EOF<BR> Response.Write objRS("LastName") & " - " & "<BR>"<BR><BR> &#039Move on to the next customer<BR> objRS.MoveNext<BR> Loop<BR> End If<BR><BR> &#039Clean up our ADO objects<BR> objRS.Close<BR> Set objRS = Nothing<BR><BR> objConn.Close<BR> Set objConn = Nothing<BR>%&#062;<BR>

  2. #2
    Mip Guest

    Default RE: Too few parameters error

    I have same problem before. But I solved it, I find out its SQL statment problem<BR>you can try the below statment to check it works or not, If it works that means other code is correct. <BR>strSQL ="SELECT * FROM NamesandAddresses" <BR><BR>then try<BR>strSQL = "SELECT FirstName, LastName, Email, HomePhone FROM NamesandAddresses" <BR><BR>then add WHERE, ORDER BY<BR><BR>step by step, you can find out what wrong with your SQL statment<BR><BR>Hope it can help<BR>*If it works, pls let me know<BR>

  3. #3
    Sathiya Guest

    Default RE: Too few parameters error

    U cant easily determine the error in the SQL statement use a Response. write strSQL to see the SQL statement is correct.This is the easy way to debug

  4. #4
    sheru Guest

    Default RE: Too few parameters error

    hi hopefully u will have to pass the cursor types ie in the line shown below do check it out: <BR>objRS.Open strSQL, objConn<BR><BR>say u can give the statement as <BR>objRS.Open strSQL, objConn, 3, 3<BR><BR>try with it ....

Posting Permissions

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