I have error of update code in asp program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tarneem
    New Member
    • Dec 2010
    • 2

    #1

    I have error of update code in asp program

    I have error in update code. It work but i not found data in Microsoft Access.
    This is the code.
    Code:
    <html>
    <body><br><br><br><br><br><br><br><br>
    <h1><center>Appointment Update
    <hr>
    <% 
    dim AppointmentID
    dim ChildID
    dim VisitID
    dim StaffID
    dim DateOfAppointment
    dim Time
    dim Remarks
    AppointmentID=request.form("AppointmentID")
    Response.write(AppointmentID)
    ChildID=request.form("ChildID")
    VisitID=request.form("VisitID")
    StaffID=request.form("StaffID")
    DateOfAppointment=request.form("DateOfAppointment")
    Time=request.form("Time")
    Remarks=request.form("Remarks")
    sql="update Appointment set ChildID='"&ChildID&"',VisitID='"&VisitID&"',StaffID='"&StaffID&"',DateOfAppointment='"&DateOfAppointment&"',Time='"&Time&"',Remarks='"&Remarks&"' where AppointmentID='"&AppointmentID&"'"
    //response.write sql
    set Conn=Server.CreateObject("ADODB.Connection")
    Conn.open "C"
    set rs=Server.CreateObject("ADODB.recordset")
    response.write("update data")
    %>
    ID of child is Updated
    
    <form  method ="POST"action="medicals.asp">
    <input type=Submit value="Back">
    </form>
    </body>
    </html>
    Please help me.
    Last edited by jhardman; Dec 29 '10, 05:27 PM. Reason: Added code tags. Please use code tags in the future.
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    So this doesn't give an error? I can think of several reasons that it would fail to update, but they should all give an error.

    Try outputting just your update statement (response.write sql) and run it in access's query analyzer? Does it work from there?

    Jared

    Comment

    • Tarneem
      New Member
      • Dec 2010
      • 2

      #3
      Hi.
      Thanks for reply my message. I edit the code but I face new error. The error is Update Statement.
      This is the code.
      <html>
      <body><br><br>< br><br><br><br> <br><br>
      <h1><center>App ointment Update
      <hr>
      <%
      dim AppointmentID
      dim ChildID
      dim VisitID
      dim StaffID
      dim DateOfAppointme nt
      dim Time
      dim Remarks
      AppointmentID=r equest.form("Ap pointmentID")
      Response.write( AppointmentID)
      ChildID=request .form("ChildID" )
      VisitID=request .form("VisitID" )
      StaffID=request .form("StaffID" )
      DateOfAppointme nt=request.form ("DateOfAppoint ment")
      Time=request.fo rm("Time")
      Remarks=request .form("Remarks" )
      set conn=Server.Cre ateObject("ADOD B.Connection")
      set rs=Server.Creat eObject("ADODB. Recordset")
      rs.open "update Appointment set ChildID='"&Chil dID&"',VisitID= '"&VisitID&"',S taffID='"&Staff ID&"',DateOfApp ointment='"&Dat eOfAppointment& "',Time='"&Time &"',Remarks='"& Remarks&"' where AppointmentID=' "&AppointmentID &"'","DSN=C"

      %>
      ID of child is Updated

      <form method ="POST"action=" medicals.asp">
      <input type=Submit value="Back">
      </form>
      </body>
      </html>

      Comment

      • jhardman
        Recognized Expert Specialist
        • Jan 2007
        • 3405

        #4
        1- print out your update statement (use response.write and the exact code you are trying to send to the db)
        2- try that update statement in a query analyzer

        I suspect the problem is you are posting text when you should be posting a number
        Code:
        childID='219' //this will probably give an error
        childID=219. //this is probably right
        The next time you post you must say that you printed out the sql statement and tested it in access or I will not answer. Also note that your code should be in code tags (use the button marked #).

        Jared

        Comment

        Working...