VB Script will not "Update" MDB file but I can run an "Insert" query just fine.

Respondida VB Script will not "Update" MDB file but I can run an "Insert" query just fine.

  • miércoles, 15 de agosto de 2012 21:17
     
      Tiene código

    I have been having some isses with my VBScript I wrote to do two functions.  First I needed the script to Insert a new records, and it does.  Second, I needed it to update an IsAvailable field that is a (Yes/No) field in Access.  That part is not working correctly.  Third, I've written a sqlLookUp statement but could never get it to execute correctly so I deleted the code before saving a backup (OOPS!).  Hopefully someone can help me here.

    <%
        dtid=Request.Form("ddlDateTime")
        
        sqlLookUp = "SELECT EOCS_Date, EOCS_Start_Time, EOCS_End_Time FROM TimeDate WHERE TimeDate_ID='" & Request.Form("ddlDateTime") & "'"
        sqlInsert = "INSERT INTO Entries (Entry_First_Name,Entry_Last_Name,TimeDate_ID) VALUES('" & Request.Form("txtFirstName") & "','" & Request.Form("txtLastName") & "','" & dtid & "')"
    
        set conn=Server.CreateObject("ADODB.Connection")
    	conn.Provider="Microsoft.Jet.OLEDB.4.0"
    	conn.Open(Server.Mappath("EOCS.mdb"))
    
        conn.Execute sqlInsert,recaffected
    
    sqlUpdate = "UPDATE TimeDate SET IsAvailable=False WHERE TimeDate_ID='" & dtid & "'" 
                on error resume next
                    conn.Execute sqlUpdate
                    If error<>0 then
                        response.write("No update permissions!")
                    else
                        response.write("Record updated!")
                    end if
                conn.close
             %>

Todas las respuestas