Syntax error in UPDATE statement

Results 1 to 2 of 2

Thread: Syntax error in UPDATE statement

  1. #1
    Join Date
    Dec 1969

    Default Syntax error in UPDATE statement

    I am really scratching my head over this one. The setup is right. Perhaps I have to define my recordset different [ specify one record set in the call, instead of looping through ]<BR><BR>-----<BR><BR> Set DataConnection = Server.CreateObject("ADODB.Connection")<BR> DataConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=E:homeintelgapublic_htmladdpagesgamed escript.mdb;"<BR> Set cmdDC = Server.CreateObject("ADODB.Command")<BR> cmdDC.ActiveConnection = DataConnection<BR> SQL = "SELECT * FROM tblGameDescription"<BR> cmdDC.CommandText = SQL<BR> Set ors = Server.CreateObject("ADODB.Recordset")<BR> ors.Open cmdDC, , 0, 2 <BR> If Not ors.BOF Then<BR> ors.MoveFirst <BR> End If<BR> Do while not ors.Fields("Name") = request.form("Name")<BR> ors.MoveNext <BR> Loop<BR> ors.Fields("Name") = Request.Form("Name")<BR> ors.Fields("GameURL") = Request.Form("GameURL")<BR> ors.Fields("Publisher") = Request.Form("Publisher")<BR> ors.Fields("PubURL") = Request.Form("PubURL")<BR> ors.Fields("Demo2") = Request.Form("Demo2")<BR> ors.Fields("Demo") = Request.Form("Demo")<BR> ors.Fields("Genre") = Request.Form("Genre")<BR> ors.Fields("SubGenre") = Request.Form("SubGenre")<BR> ors.Fields("MP") = Request.Form("MP")<BR> ors.Fields("MPAmount") = Request.Form("MPAmount")<BR> ors.Fields("Description") = Request.Form("Description")<BR> ors.Fields("By") = Request.Form("By")<BR> ors.Fields("SubmitDate") = Request.Form("SubmitDate")<BR> ors.Fields("ComSite1") = Request.Form("ComSite1")<BR> ors.Fields("ComSite2") = Request.Form("ComSite2")<BR> ors.Fields("Comsite3") = Request.Form("ComSite3")<BR> ors.Update<BR> ors.close<BR> Set ors = Nothing<BR> Set cmdDC = Nothing<BR> DataConnection.Close<BR> Set DataConnection = Nothing<BR> response.write "Game modified."<BR><BR>-----<BR><BR>thanks

  2. #2
    Chris Chen Guest

    Default RE: Syntax error in UPDATE statement

    If you can post the error message, it would be much easier since the error message could help everyone pinpoint the source of error.<BR>This is my suggestion, not sure if it will help:<BR>1. First, you use name field to find the record with the same value, but what would happen if multiple records have the same value? If would be better if you can include autonumber(or the primary key, or anything that has unique value in your table) to update the exact record you want.<BR>2. you could simplify the connection with fewer steps. I&#039m not sure if the cmdDC = Server.CreateObject("ADODB.Command") is really necessary. I might be wrong.<BR>3. Rather than using RecordSet update function, it would be much better to update using SQL command. Use &#062;WHERE NAME = "something" &#060; clause to update. You can find the appropriate articles with Unless SQL isn&#039t an option.<BR>4. Sorry I couldn&#039t really pinpoint the problem =)

Posting Permissions

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