Update sql statement in ASP

Results 1 to 2 of 2

Thread: Update sql statement in ASP

  1. #1
    Join Date
    Dec 1969

    Default Update sql statement in ASP

    Hi,<BR>I am trying to update fields in my database. I have tried a number of ways and the following code seems to be the only way that works. However I am getting the following 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>I don&#039;t get this error when I only have the first condition in the where clause. I need to specify the conditiond??<BR>Am I allowed have more than one condition in the where clause? Has anyone any suggestions on how I could do it differently???<BR><BR>This is my code:<BR><BR>Dim dbCon &#039;Holds the Database Connection Object<BR>Dim strSQL &#039;Holds the SQL query to query the database <BR><BR>&#039;Create an ADO connection object<BR>Set dbCon = Server.CreateObject("ADODB.Connection")<BR>dbCon.O pen "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("grades.mdb")<BR><BR><BR>for i = 0 to ubound(arrstudentid) - 1<BR><BR>if (session("sTerm") = "Christmas") then<BR> <BR> strSQL = "UPDATE AllocatedClass SET Grade1 = &#039;" & arrGrade(i) & "&#039; WHERE (AllocatedClass.StudentID = " & arrstudentid(i) & ") and (AllocatedClass.ClassID = " & session("sClasses") & ") and (AllocatedClass.SubjectName = " & session("sSubjects") & ")"<BR> dbCon.Execute(strSQL)<BR><BR> strSQL = "UPDATE AllocatedClass SET Percentage1 = &#039;" & arrpercent(i) & "&#039; where AllocatedClass.StudentID = " & arrstudentid(i) & ""<BR> dbCon.Execute(strSQL)<BR><BR> strSQL = "UPDATE AllocatedClass SET Comments1 = &#039;" & arrcomments(i) & "&#039; WHERE AllocatedClass.StudentID = " & arrstudentid(i) & ""<BR> dbCon.Execute(strSQL)<BR> <BR> End if<BR><BR>Next<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default ASPFAQs, category Databases, Errors

    The link to the ASPFAQs is at the top right corner of this very page.<BR><BR>Look in the category noted in the subject of this post for your FAQ.<BR><BR>How come you use *THREE SEPARATE* queries to update one single record???? What&#039;s the point of that?<BR><BR>And if you want people to try to figure out *WHAT* your error is, it helps to tell WHERE you are getting it from.<BR><BR>

Posting Permissions

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