PDA

View Full Version : what does this error mean?


helLO
04-17-2003, 02:25 PM
what does this error mean when i try to update something to the database?

Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'test'. Make sure it exists and that its name is spelled correctly.

test.asp, line 35

raf
04-17-2003, 02:52 PM
:)
it means you are using some code from somewhere :)

You're tryng to browse a page with an sql statement in it, that runs on a db with a table called test. If you wan't the code to be working, you need to create a table "test" in your db (+all variables in that table that are used in the code)

helLO
04-17-2003, 04:17 PM
I have the DNS and the table created...

if SAT= "HARD" then
SAT= "SOFT"
else

end if


objrs.Open "UPDATE test SET name='"&SAT&"' WHERE nameID='"&ID&"'" ,objConn


Am doing the right thing?

raf
04-17-2003, 05:05 PM
try this:
[code]
if SAT= "HARD" then
SAT= "SOFT"
end if

dim sql
sql="UPDATE test SET name='thename' WHERE nameID=theid"
sql=replace(sql,"thename",SAT)
sql=replace(sql,"theid",ID)

objConn.Execute sql
[code]
you don't need a recordset, and i assume that the nameID is numeriv variable. if the table exists, this should work. make sure your working with the right db an triplecheck if the table exists:)

helLO
04-17-2003, 05:20 PM
SOFT

Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

test.asp, line 37


the code at Line 37---> objConn.Execute sql

raf
04-17-2003, 05:33 PM
you should have this

objConn.Execute sql

where objConn is your name for the ADODB connection.
Like

set objConn=server.createobject("ADODB.connection")
objConn.open "dbname"

But actually, you'd better use a DSN-less connection ...

helLO
04-17-2003, 05:39 PM
Sorry... I copied wrongly...

it is objConn.Execute sql... can't seem to work...

raf
04-17-2003, 05:43 PM
maybe post the code and tell us if it's still the same error.

helLO
04-17-2003, 06:23 PM
The code should be like this...

lat = request.form("number_of")

for i=1 to lat

'I use checkboxes here.
if request.form("checkboxes" & i)="on" then

NameID = request.form("ID" & i)

Name = request.form("sat" & i)

if sat= "HARD" then
sat= "SOFT"
end if

dim sql
sql="UPDATE test SET name='thename' WHERE nameID=theid"
sql=replace(sql,"thename",SAT)
sql=replace(sql,"theid",ID)

objConn.Execute sql

else

end if
next
%>

raf
04-17-2003, 06:30 PM
what is this sat? it'll always be empty is this code?
if sat= "HARD" then


look at the sql statement that is processed, by inserting this before objConn.Execute sql :

response.write sql
response.end

then load the page into your browser and look at the sql-statement that is displayed. it think it'll have SET name=''

helLO
04-18-2003, 02:36 PM
sat is just a variable i declared in that page... In the database, there is a column called name... before it comes to this page, it had data called HARD... I want to change it to SOFT when it come to this page...


When i put this code <response.write sql
response.end> before the execute statement, i got msg like this...


SOFTUPDATE test SET sat='thename' WHERE nameID='HARD'

raf
04-18-2003, 03:02 PM
When i put this code <response.write sql
response.end> before the execute statement, i got msg like this...
SOFTUPDATE test SET sat='thename' WHERE nameID='HARD'

Good. I mean Bad, bad.
The "UPDATE test SET sat='thename' WHERE nameID='HARD'" you see is the sql that will be executed. Now the problem is the 'thename'. It should have been replaced by the value of the variable SAT. So there is a typo in your sql statement or in the relace line.

Also, is there a variable called sat in your table? In your previous code, the variablename was name.
Also ' nameID='HARD' ' looks strange to me.
Can you post the table design --> the variables you try to update + the one from the condition. Are they really sate? Can 'HARD' be a value of nameID?

helLO
04-18-2003, 03:28 PM
Ok... I try to rephrase the whole codes again.. I find it quite messy...

<html>
<body>
<%@ language = "VBScript"%>


<%
dim ended, chang, nam

Dim objconn
Dim objrs
Set objconn = Server.CreateObject("ADODB.Connection")
Set objrs = Server.CreateObject("ADODB.Recordset")
objconn.Open "testing"


ended = request.form("looping")

for i=1 to ended


if request.form("choice" & i)="on" then

nam = request.form("user_name" & i)

chang = request.form("state" & i)

if chang = "HARD" then
chang = "SOFT"

end if

response.write(chang)
response.write(nam)
dim sql
sql="UPDATE test SET chang='thechang' WHERE nam='thename'"
sql=replace(sql,"thename",chang)
sql=replace(sql,"thename",user_name)

response.write sql
response.end
objconn.Execute sql


else

end if
next
%>



<%
objrs.Close
objconn.Close
Set objrs=Nothing
Set objconn=Nothing
%>

</body>
</html>


User_name and state are in my table.... choice is the name of the checkboxes that i made in the previous page... If u need me to explain my codes further, pls let me know...

raf
04-18-2003, 04:33 PM
Hmm. We're not really making progress. Not wanna put you down, but you should read a good tutorial or so on ASP.

About the code. You've got:

sql="UPDATE test SET chang='thechang' WHERE nam='thename'"
sql=replace(sql,"thename",chang)
sql=replace(sql,"thename",user_name)

What happens is that the sql value will be this

sql="UPDATE test SET chang='thechang' WHERE nam='thename'"
sql="UPDATE test SET chang='thechang' WHERE nam='value of chang'"
sql="UPDATE test SET chang='thechang' WHERE nam='value of user_name'"

Which is probably not what you need. You change the valie for nam two times? And leave the value for chang unchanged.

User_name and state are in my table
:confused: If you replcace thename with user_name, then this means user_name should be a variable in your asp script tha hase some value. In doent saw that?

If this code is correct then you have the variables (cuolumns) chang and nam in your table. Not user_name and state

<html>
<body>
<%@ language = "VBScript"%>


change that to
<%@ language = "VBScript"%>
<html>
<body>

helLO
04-18-2003, 05:40 PM
Those codes that i posted just now are amended with yr suggestions... Maybe because of the confusing codes and i didn't explain it well enough... sorry abt that...

Intially, the codes are:

<%@ language = "VBScript"%>


<html>
<body>


<%
dim ended, chang, nam

Dim objconn
Dim objrs
Set objconn = Server.CreateObject("ADODB.Connection")
Set objrs = Server.CreateObject("ADODB.Recordset")
objconn.Open "testing"


ended = request.form("looping")

for i=1 to ended


if request.form("choice" & i)="on" then

nam = request.form("user_name" & i)

chang = request.form("state" & i)

if chang= "HARD" then
chang= "SOFT"

end if

response.write(chang)
response.write(nam)
objrs.Open "UPDATE test SET state='"&chang&"' WHERE nam ='"&user_name&"'" ,objconn
else

end if
next
%>


<%
objrs.Close
objconn.Close
Set objrs=Nothing
Set objconn=Nothing
%>

</body>
</html>

user_name and state are in the table... testing is the name of the DSN and test is the table name...

I'm not sure is this the way to SET(do i have to remove the double quotes or &?)-->objrs.Open "UPDATE test SET state='"&chang&"' WHERE nam ='"&user_name&"'" ,objconn

This whole codes got an error:

SOFT
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

test.asp, line 33

line33-->objrs.Open "UPDATE test SET state='"&chang&"' WHERE nam ='"&user_name&"'" ,objconn

raf
04-18-2003, 07:13 PM
You've got two ways of running the sql statement:
rsRecorsetname.Open sql, connectionname
(i only use thif form for selectstatement)

and

connectionname.Execute sql

You kinda seem to have mixed them.
Should be
objConn.Execute sql

miranda
04-18-2003, 08:17 PM
If you are using a SQL statement to do an update you do not need to use the recordset object

just use the connection objects execute method to handle it.

helLO
05-13-2003, 12:09 PM
Thanks for the help and explainations...
:)