Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting record code fails - why?

Status
Not open for further replies.

LEICJDN1

Technical User
Nov 27, 2002
201
0
0
GB
Me again...

I have selected a recordset then passed its corresponding ID along to another page, where I then intend to delete the record.

Here is my current code:

Code:
deltarget=CInt(Request.Querystring) 'sent as link.asp?4 for example
strConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\[URL unfurl="true"]wwwroot\Refman\refdb.mdb"[/URL]
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open strConnectionString
sql="DELETE * FROM reftable WHERE ID=" &deltarget& ";"
cnn.Execute sql
cnn.close
Set cnn=nothing

It runs but I get an 8000405 error 'Could not delete from specified tables'

I know deltarget is correct, and that a record exists with that ID.

The ID field is an autonumber field and also the primary key.

Any ideas why the above fails?
 
remove the * from the sql string.

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
I tried that before with no joy.

Is it because I have a primary key?
 
Sorrry to post back to my own query but someone else may have the same problem. It is to do with permission, and I solved it by navigating to the 'inetpub' folder on my HD and ensuring it is set to share across networks and other users which then set this permission for the whole folder.

Deletions now fine.
 
Hi,

Can you let me know how you checked the inetpub folder?

I'm having trouble adding a new record and could do with any suggestions!!

Lucy
 
Just went to the hard drive root, right clicked inetpub, chose properties then fiddled with the sharing settings.
 
Actually, it seems to be more complex than that.

I set the folder containing my web and db (in to share across networks and also web share. This allowed deletion of records with no problem. However, addition of records was stuffed, and bizarrely my form 'posting' data to other ASP pages would also not work. Most odd.

Final solution was to have the ASP pages in another folder, which is only set to network share and not web share, and to have the database in separate folder set to network share and web share.

Now all seems to be behaving but I can't for the life of me figure out why my Forms suddenly stopped working just because folder sharing was set to web share.

Hope that makes some sense!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top