This topic is locked

Delete record through a multi-table query

6/25/2004 3:11:39 PM
ASPRunnerPro General questions
author

Hi
I'm using AspRunner over MsAccess 2000 database. AspRunner is using a query to select from two tables that are linked through a one-to-many relationship.
table1: tbl_Rooms fields: R_ID, R_Name, R_TypeID

table2: tbl_Types fields: T_ID, T_Name

query: qr_RoomsInfo

SELECT tbl_Rooms.R_ID, tbl_Rooms.R_Name, tbl_Types.T_Name

FROM tbl_Types INNER JOIN tbl_Rooms ON tbl_Types.T_ID = tbl_Rooms.R_TypeID;
AspRunner works fine and I can list/add/modify/search without any problem.

When I try to delete a record though, I get the following error:
-2147467259

Error description [Microsoft][ODBC Microsoft Access Driver] Could not delete from specified tables.

URL /qr_roomsinfo_list.asp

SQL query delete from [qr_RoomsInfo] where [R_ID]=205
For some reason I can't delete a record from a query if it has data from different tables. I have referencial integrity and cascade update/delete enabled for the relationship between the two tables and I'm able to delete records if I apply the delete query directly to the tbl_Rooms table and through the qr_RoomsInfo query.
As far as I understand this is not a problem related to AspRunner, which by the way is amazingly useful, but has to do with the way MsAccess works.
Please provide any clues.
thanx

Nikos

Sergey Kornilov admin 6/26/2004

Nikos,
this problem happens because MS Access don't know what table to use for deletion when you run DELETE against a query. You will need to replace the following section in ...list.asp file:

strSQL="delete from " & strTableName &


with

strSQL="delete from " & "tblRooms" &


I hope this helps.

500141 6/26/2004

Indeed it is going to work that way.

Thanx, Sergey

Nikos