Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Delete recs from DB ??

I have an ASP problem that might interest ya. Attempting to delete from an Access DB and receiving the following error:

=======================
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.
/shans/FinalProject/ProcessDelete1.asp
=======================

Does this have to do with server access permissions ?
Or is it just my code, pretty sure the problem exists within or near the delete statement:
[code]
<%
Dim objConn, strPath, objRS, strSQL, numID
numID = request.form("frmID")
if cint(numID) = 1 then
response.write "body bgcolor=""#ffffff"">

You cannott delete User 1 because that is the Administrator. Try another ID.

" &_
"

back

"
response.end
end if
strPath = Server.MapPath("/shans/db/Mydb.mdb")
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strPath

'Recordset record retrieval
strSQL = "SELECT FROM Members where ID = " & numID

Set objRS = objConn.Execute(strSQL)

'If no record found for this ID
If objRS.EOF And objRS.BOF Then
Set objRS = Nothing 'release memory
Set objConn = Nothing 'release memory
response.redirect "NotFound1.asp?id=" & numID
else
[red]
'Delete record from table by ID
strSQL = "DELETE * FROM Members where ID = " & numID
objConn.Execute(strSQL)
[/red]
Set objRS = Nothing 'release memory
Set objConn = Nothing 'release memory
response.redirect "accessible1.asp"
End If
%>
[/code]
Confused because everything works fine up until I try to actually delete records(all the simple validation checks run OK)
Would appreciate your help.

Thanks.


Comments

  • bagles1bagles1 Member Posts: 54
    The error is in the delete statement. Delete statements mean you are deleting a row in a table so you can NOT specify columns. It is similar to saying I want to only delete the columns in this row.... That can't be done. Your sql statement should work fine if you remove the asterisk, like this:

    strSQL = "DELETE FROM Members where ID = " & numID

    -Bagles1


    : I have an ASP problem that might interest ya. Attempting to delete from an Access DB and receiving the following error:
    :
    : =======================
    : Error Type:
    : Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    : [Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.
    : /shans/FinalProject/ProcessDelete1.asp
    : =======================
    :
    : Does this have to do with server access permissions ?
    : Or is it just my code, pretty sure the problem exists within or near the delete statement:
    : [code]
    : <%
    : Dim objConn, strPath, objRS, strSQL, numID
    : numID = request.form("frmID")
    : if cint(numID) = 1 then
    : response.write "body bgcolor=""#ffffff"">

    You cannott delete User 1 because that is the Administrator. Try another ID.

    " &_
    : "

    back

    "
    : response.end
    : end if
    : strPath = Server.MapPath("/shans/db/Mydb.mdb")
    : set objConn = Server.CreateObject("ADODB.Connection")
    : objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strPath
    :
    : 'Recordset record retrieval
    : strSQL = "SELECT FROM Members where ID = " & numID
    :
    : Set objRS = objConn.Execute(strSQL)
    :
    : 'If no record found for this ID
    : If objRS.EOF And objRS.BOF Then
    : Set objRS = Nothing 'release memory
    : Set objConn = Nothing 'release memory
    : response.redirect "NotFound1.asp?id=" & numID
    : else
    : [red]
    : 'Delete record from table by ID
    : strSQL = "DELETE * FROM Members where ID = " & numID
    : objConn.Execute(strSQL)
    : [/red]
    : Set objRS = Nothing 'release memory
    : Set objConn = Nothing 'release memory
    : response.redirect "accessible1.asp"
    : End If
    : %>
    : [/code]
    : Confused because everything works fine up until I try to actually delete records(all the simple validation checks run OK)
    : Would appreciate your help.
    :
    : Thanks.
    :
    :
    :

  • damind_007damind_007 Member Posts: 18
    Thank you for your assistance.

    Unfortunately I tried to remove the asterisk from the SQL statement w/ no success?
    See anything else that may be causing this error?


    : The error is in the delete statement. Delete statements mean you are deleting a row in a table so you can NOT specify columns. It is similar to saying I want to only delete the columns in this row.... That can't be done. Your sql statement should work fine if you remove the asterisk, like this:
    :
    : strSQL = "DELETE FROM Members where ID = " & numID
    :
    : -Bagles1
    :
    :
    : : I have an ASP problem that might interest ya. Attempting to delete from an Access DB and receiving the following error:
    : :
    : : =======================
    : : Error Type:
    : : Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    : : [Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.
    : : /shans/FinalProject/ProcessDelete1.asp
    : : =======================
    : :
    : : Does this have to do with server access permissions ?
    : : Or is it just my code, pretty sure the problem exists within or near the delete statement:
    : : [code]
    : : <%
    : : Dim objConn, strPath, objRS, strSQL, numID
    : : numID = request.form("frmID")
    : : if cint(numID) = 1 then
    : : response.write "body bgcolor=""#ffffff"">

    You cannott delete User 1 because that is the Administrator. Try another ID.

    " &_
    : : "

    back

    "
    : : response.end
    : : end if
    : : strPath = Server.MapPath("/shans/db/Mydb.mdb")
    : : set objConn = Server.CreateObject("ADODB.Connection")
    : : objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strPath
    : :
    : : 'Recordset record retrieval
    : : strSQL = "SELECT FROM Members where ID = " & numID
    : :
    : : Set objRS = objConn.Execute(strSQL)
    : :
    : : 'If no record found for this ID
    : : If objRS.EOF And objRS.BOF Then
    : : Set objRS = Nothing 'release memory
    : : Set objConn = Nothing 'release memory
    : : response.redirect "NotFound1.asp?id=" & numID
    : : else
    : : [red]
    : : 'Delete record from table by ID
    : : strSQL = "DELETE * FROM Members where ID = " & numID
    : : objConn.Execute(strSQL)
    : : [/red]
    : : Set objRS = Nothing 'release memory
    : : Set objConn = Nothing 'release memory
    : : response.redirect "accessible1.asp"
    : : End If
    : : %>
    : : [/code]
    : : Confused because everything works fine up until I try to actually delete records(all the simple validation checks run OK)
    : : Would appreciate your help.
    : :
    : : Thanks.
    : :
    : :
    : :
    :
    :



  • StPatrickStPatrick Member Posts: 76
    BTW, do you have write access to this directory? IUSR_... (Internet Guest Account) should have write and modify access rights in order to change/delete something in database. Can you delete from other tables?

    [b][italic]Philip Patrick[/italic][/b]
    [b]Home page[/b]: http://www.stpworks.com
    [size=1][italic]"Two beer or not two beer?"[/italic] [b]Shakesbeer[/b][/size]

  • aflat362aflat362 Member Posts: 50
    Try this:
    strSQL = "DELETE FROM Members where ID ='" & numID & "'"

    : Thank you for your assistance.
    :
    : Unfortunately I tried to remove the asterisk from the SQL statement w/ no success?
    : See anything else that may be causing this error?
    :
    :
    : : The error is in the delete statement. Delete statements mean you are deleting a row in a table so you can NOT specify columns. It is similar to saying I want to only delete the columns in this row.... That can't be done. Your sql statement should work fine if you remove the asterisk, like this:
    : :
    : : strSQL = "DELETE FROM Members where ID = " & numID
    : :
    : : -Bagles1
    : :
    : :
    : : : I have an ASP problem that might interest ya. Attempting to delete from an Access DB and receiving the following error:
    : : :
    : : : =======================
    : : : Error Type:
    : : : Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    : : : [Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.
    : : : /shans/FinalProject/ProcessDelete1.asp
    : : : =======================
    : : :
    : : : Does this have to do with server access permissions ?
    : : : Or is it just my code, pretty sure the problem exists within or near the delete statement:
    : : : [code]
    : : : <%
    : : : Dim objConn, strPath, objRS, strSQL, numID
    : : : numID = request.form("frmID")
    : : : if cint(numID) = 1 then
    : : : response.write "body bgcolor=""#ffffff"">

    You cannott delete User 1 because that is the Administrator. Try another ID.

    " &_
    : : : "

    back

    "
    : : : response.end
    : : : end if
    : : : strPath = Server.MapPath("/shans/db/Mydb.mdb")
    : : : set objConn = Server.CreateObject("ADODB.Connection")
    : : : objConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strPath
    : : :
    : : : 'Recordset record retrieval
    : : : strSQL = "SELECT FROM Members where ID = " & numID
    : : :
    : : : Set objRS = objConn.Execute(strSQL)
    : : :
    : : : 'If no record found for this ID
    : : : If objRS.EOF And objRS.BOF Then
    : : : Set objRS = Nothing 'release memory
    : : : Set objConn = Nothing 'release memory
    : : : response.redirect "NotFound1.asp?id=" & numID
    : : : else
    : : : [red]
    : : : 'Delete record from table by ID
    : : : strSQL = "DELETE * FROM Members where ID = " & numID
    : : : objConn.Execute(strSQL)
    : : : [/red]
    : : : Set objRS = Nothing 'release memory
    : : : Set objConn = Nothing 'release memory
    : : : response.redirect "accessible1.asp"
    : : : End If
    : : : %>
    : : : [/code]
    : : : Confused because everything works fine up until I try to actually delete records(all the simple validation checks run OK)
    : : : Would appreciate your help.
    : : :
    : : : Thanks.
    : : :
    : : :
    : : :
    : :
    : :
    :
    :
    :
    :

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    ___ | http://forcoder.org | free video tutorials and ebooks about [ C, Objective-C, JavaScript, Assembly, C++, Python, MATLAB, Scratch, Visual Basic .NET, R, C#, Visual Basic, PL/SQL, Swift, Java, PHP, Go, Ruby, Delphi, Perl Dart, Lua, Fortran, COBOL, Erlang, ML, Kotlin, VBScript, F#, Hack, Crystal, Ada, SAS, Transact-SQL, Scala, D, Apex, Awk, FoxPro, Bash, Clojure, Logo, Scheme, Julia, ABAP, Rust, Lisp, LabVIEW, Prolog, Alice ] ______________

Sign In or Register to comment.