Link to home
Start Free TrialLog in
Avatar of dinx
dinx

asked on

ODBC error 80040e10: wrong number of parameters

I am trying to put some data from a web page into a database using an SQL string. Most of the times it works perfectly well, but some users complain that they get an error message as follows:

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft] [ODBC Microsoft Access 97 Driver] Wrong number of parameters
/inputpage.asp, line 90

Line 90 contains the line:
 conntemp.open myDSN
where 'myDSN' is defined as follows:
 myDSN="DSN=database"


I searched the web for solutions to this problem, but I only can find pages about a slightly different message with the same code, but the text 'too few parameters' instead of 'wrong number of parameters'. And the solutions I have found there don't seem to count for my problem.

Does anyone have any ideas? Thanks!
Avatar of rgroves
rgroves

The error message is coming from your ODBC driver, not necessarily a problem with your ASP code..

Your conntemp might be a recordset object instead of a connection object.

Make sure you declare it as:

set conntemp = Server.CreateObject("ADODB.Connection")
myDSN = "DSN=database"
conntemp.open myDSN
If some values of the web page are not filled and if its assuming to be null then the sQL Statment may be getting a mismatch.

Just print the sql statement before the execute sql statement to see if the fields and input values match.

typically

<%
sqlinsertstring = ...............
%>
Your insert statement.

<%
set conn = Server.CreateObject("ADODB.Connection")
    conn.open "databasename"

or as rgroves mentioned earlier give the dsn name.

as

 conn.open "DSN=databasename;"
%>
<%=insertsqlstring%><%
 conn.execute(insertsqlstring)

Just try it.
Anjana
Okay I've actually gotten this error before so no matter what we'll get this solved.  Here's the way's I worked around it:

First off, in any variables that could be NULL when being entered into the database or could be passed to the SQL string, make sure to declare them as such.  For example:  @name, @address, @city, @state, @zip, @phone = NULL, @accountNumber    etc. etc.

You need to have the variable or input parameter of @phone = to NULL in case the SQL statement is passed a null value.  If it's passed an actual value, don't worry the value will still go into the database.  But if it's NULL then = NULL part will cover it.

Your problem more than not is passing your SQL a NULL value from the form.
ASKER CERTIFIED SOLUTION
Avatar of mustafa_guney
mustafa_guney

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial