Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

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!
0
dinx
Asked:
dinx
1 Solution
 
rgrovesCommented:
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
0
 
qualityacubeCommented:
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
0
 
jbilstenCommented:
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.
0
 
mustafa_guneyCommented:
You must not send string or "" to numeric value
you have to control value of variable
for example
if request.form("a")<>"" then

or
if not isnumeric("a") then
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now