Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO UPDATE record fail

Status
Not open for further replies.

2122002

IS-IT--Management
Apr 22, 2003
58
US
Dear All,

Ive been battling with below codes. All I want is to update the "Student" table ni MS-Access. I use DNS-less connectoin. the error i keep getting "Too few parameters. Expected 2" error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
/CourseSelector/Admin/stud_edition.asp, line 16

Line 16 is "myConn.execute sql"

====================================================
here is my update code:


<%

Dim myConn, rsEducation , sql,strStudentId, strSurname, strForename, strCohortId, strEducation1, strEducation2
ID=Request.Form("ID")

set myConn=Server.CreateObject("ADODB.Connection")
myConn.Open "Student"
set rsEducation = Server.CreateObject("ADODB.Recordset")

strSurname= Request.Form("Surname")
strForename= Request.Form("forenames")
strEducation1= Request.Form("education1")
strEducation2= Request.Form("education2")

SQL = "UPDATE [students] SET Students.Surname=('"& strSurname&"'), Students.forename=('"& strForename&"'), Students.education1=('"& strEducation1&"'), Students.education2=('"& strEducation2&"') WHERE Students.StudentID =" & ID & ";"

myConn.execute sql

%>
<p><b><font face="Tahoma" color="#666666">Student Educational background is upadted ! </font></b></p>
<p>&nbsp;</p>
<input type="button" value=" &lt;&lt; Back " onClick="javascript:window.navigate('editstud.asp')">
</body>
</html>

Dan
 
seems to be a school assignment. is that correct?

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Click here to find out why.

 
Hello, this has nothing to do with school. Its a customise private project.


Dan
 
try this:

Code:
SQL = " UPDATE Students SET"&_
      " Surname='"& strSurname&"',"&_
      " forename='"& strForename&"',"&_
      " education1='"&strEducation1&"',"&_
      " education2='"& strEducation2&"' WHERE"&_ 
      " StudentID ="&ID; "

also do a response write SQL to see the actual sql query being passed...

make sure that ID is not empty...

-DNG
 
Still same story. I actually defined constraint on cascasde and on update. however, I've removed the constraint but still give error.

Any other style / method of updating records / multiple record?.

regards.



Dan
 
can you please show us what you get when you do...

Code:
response.write SQL

-DNG
 
when I used this command "response.write SQL", then I get this result:

UPDATE Students SET Surname='Nichola', forename='James', education1='Olevel', education2='none' WHERE StudentID =22222;

==============================

When I used "myConn.Execute sql" then I get this error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.


Dan
 
can you copy and paste this query

Code:
UPDATE Students SET Surname='Nichola', forename='James', education1='Olevel', education2='none' WHERE StudentID =22222;

in access and check if it is working...

-DNG
 
ITS NOW WORKING. here is my mistake:

"forenames"

it should be strForename= Request.Form("forename")

MANY THANKS TO YOU ALL!!!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top