I have dynamic ASP web site that I'm interfacing to a MS ACCESS dB where I'm performing add, edit and delete functions. With the delete function I'm using a confirmation dialog box and everything appears to work great except it doesn't actually delete the record. Can anyone shed some light on my coding issue?? I've attached my code below:
Thanks is advance
jknouse
==========================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Untitled
<%
' The above line is for ADODB Constants
' For more info see "What is Adovbs.inc and Why Do I Need It?"
' @
http://www.asp101.com/articles/john/adovbs/default.asp
Dim DB_CONNECTIONSTRING ' DB connection string
' Basic Access OLE DB connection
DB_CONNECTIONSTRING = "DSN=nbo_ssc;DRIVER={Microsoft Access Driver}"
Dim cnnConnection
Dim rstShowTable
Dim objField
Dim iLooper
Dim iRecordCount
Dim strRecordsToDelete
Dim strSQL
Dim lngRecordsAffected
Const strTableName = "action_log"
Const strPrimaryKeyFieldName = "autoAIID"
CONST strTable2Name = "Action_Log_2"
' Open our connection:
Set cnnConnection = Server.CreateObject("ADODB.Connection")
cnnConnection.Open DB_CONNECTIONSTRING
' First we see if we've got any records to delete.
strRecordsToDelete = Request.Form(strPrimaryKeyFieldName)
' Quick test to make sure all entries are numeric.
Dim arrTest
arrTest = Split(strRecordsToDelete, ", ")
For iLooper = LBound(arrTest) To UBound(arrTest)
If Not IsNumeric(arrTest(iLooper)) Then strRecordsToDelete = ""
Next
If strRecordsToDelete <> "" Then
strSQL = "DELETE FROM " & strTable2Name & " WHERE " & strPrimaryKeyFieldName _
& " IN (" & strRecordsToDelete & ")"
'Response.Write strSQL
cnnConnection.Execute strSQL, lngRecordsAffected, adExecuteNoRecords
Response.Write "
" & lngRecordsAffected & " Record(s) Deleted! (" _
& Request.Form(strPrimaryKeyFieldName) & ")
"
End If
' Next we show the records currently in the table. I'm showing all
' this table's records, but if your table is large you'll want to
' either show a page at a time or run a query to narrow them down
' to a reasonable number.
'
%>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("../../../Database/NBO_SSC.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT DISTINCT IMDS_Primary FROM Action_Log WHERE Manager='RArcell' ORDER BY IMDS_Primary ASC"
rs.Open sql,conn
name=request.form("IMDS_Primary")
%>
Select Associate's Name
<% do until rs.EOF
response.write("<option")
if rs.fields("IMDS_Primary")=name then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("IMDS_Primary"))
rs.MoveNext
loop
rs.Close
set rs=Nothing %>
<%
if name<>"" then
sql="SELECT IMDS_Primary, AIID, Priority, Description, Notes, Open_Date, AutoAIid FROM Action_Log WHERE IMDS_Primary='" & name & "' ORDER BY IMDS_Primary ASC, Type ASC, SortOrder ASC"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>
<%Function IIf(bArg,sTrue,sFalse)
If bArg = True Then IIF = sTrue
If bArg = False Then IIF = sFalse
End Function%>
<%
strSQL = "SELECT IMDS_Primary, AIID, Priority, Description, Notes, Open_Date, AutoAIid FROM Action_Log WHERE IMDS_Primary='" & name & "' ORDER BY IMDS_Primary ASC, Type ASC, SortOrder ASC"
Set rstShowTable = Server.CreateObject("ADODB.Recordset")
rstShowTable.Open strSQL, cnnConnection, adOpenStatic, adLockPessimistic, adCmdText
' Write out title row
Response.Write "
" & objField.Name & " | Delete? |
---|
" & rstShowTable.Fields(iLooper).Value _
& " | "
Response.Write ""
Response.Write " |
[/TH]" & vbCrLf
Next
Response.Write vbTab & vbTab & "[TD] | |