DELETE FROM passprotected database (Jet error 80004005)
am 24.05.2005 15:12:20 von Tim.Vanlaere
Hi,
Yesterday I changed my code to add authentication to my Access
Databases.
Ever since attempting to remove entries from my database are is
unsuccessfull.
My code-snippets to read/edit the database work like a charm, but it's
removing data which gives errors of which I'm not sure how to get pass.
--include--
Dim pwd
pwd = "password"
Pathto = Server.MapPath("/some/database.mdb")
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
set rs = Server.CreateObject("ADODB.recordset")
conn.Properties("Jet OLEDB:Database Password") = pwd
-/include--
--code--
' complains about authentication w/o this line
conn.Properties("Jet OLEDB:Database Password") = pwd
Response.Write querytbl
conn.mode = adModeWrite
conn.Open pathto
rs.Open querytbl,conn,1,1
rs.close
conn.Close
-/code--
That snippet gives me the error (ID is in de database a Autonumbering
ID):
--error--
DELETE FROM Root_Items WHERE ID=32
Provider error '80040e21'
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.
-/error-
I've tried to move the adModeWrite above the properties declaration,
but it gives me a "Microsoft JET Database Engine error '80004005'/Could
not delete from specified tables."-error. Which is to my conclusion
cause the adModeWrite isn't passed that way.
Thanks in advance,
Tim
Re: DELETE FROM passprotected database (Jet error 80004005)
am 24.05.2005 16:48:06 von Tim.Vanlaere
Please disregard my comment, I was able to solve my problem with the
following snippet;
--code--
conn.mode = adModeWrite
conn.Properties("Jet OLEDB:Database Password") = pwd
conn.Open pathto
rs.Open querytbl,conn
' rs.close gives errors on queries which do not return rows
conn.Close
-/code--
Tim
Re: DELETE FROM passprotected database (Jet error 80004005)
am 25.05.2005 13:16:57 von reb01501
Tim wrote:
> Please disregard my comment, I was able to solve my problem with the
> following snippet;
>
> --code--
> conn.mode = adModeWrite
> conn.Properties("Jet OLEDB:Database Password") = pwd
> conn.Open pathto
> rs.Open querytbl,conn
> ' rs.close gives errors on queries which do not return rows
Do not open a recordset on a query that does not return records. That is
extremely wasteful! Use the connection's Execute method to, well, execute,
action queries, and you should tell ADO not to
bother creating a recordset object in the background (which it does by
default)
'if you've included the adovbs.inc file, or used a meta tag
'to reference the ADO type library, these two lines will
'not be needed:
const adCmdText=1
const adExecNoRecords
conn.Execute querytbl,,adCmdText + adExecNoRecords
You should give these posts a read:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1& selm=eHYxOyvaDHA.4020%40tk2msftngp13.phx.gbl
http://groups-beta.google.com/group/microsoft.public.inetser ver.asp.db/msg/72e36562fee7804e
Your use of dynamic sql is leaving your site open to attack via sql
injection:
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23
http://www.nextgenss.com/papers/advanced_sql_injection.pdf
http://www.nextgenss.com/papers/more_advanced_sql_injection. pdf
http://www.spidynamics.com/papers/SQLInjectionWhitePaper.pdf
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"