asp.net - Appropriate AccessDataSource Delete command or tweaking? -


using accessdatasource , listview when hit del in browser following error shown

oledbexception (0x80004005) : record cannot deleted or changed because table 'tblorders' includes related records.

i trying solve problem through couple of ways follows

deletecommand="delete [tblcustomers] , [tblorders] [pkeycustomerid] = ? " 

the default command generated asp is

deletecommand="delete [tblcustomers] (([pkeycustomerid] = ?) or ([pkeycustomerid] null , ? null)) " 

or

i removed <asp:parameter name="pkeycustomerid" type="string" /> <deleteparameters> , replace parameters of selected table foreign key issue isnt affected tag there no errors record isnt deleted either

how around this?

your first query:

delete [tblcustomers] , [tblorders] [pkeycustomerid] = ?  

is not valid syntax, cannot delete 2 tables simulatenously, need

delete [tblorders] [pkeycustomerid] = ?; delete [tblcustomers] [pkeycustomerid] = ?; 

however don't think access supports multiple statements. best solution edit relationship use cascade delete referential action trigger.

to go relationships in access:

enter image description here

then double click on relationship between tblorders , tblcustomers bring properties. either uncheck "enforce referential integrity", or ensure cascade referential action options checked (ignore field names, first relation came across in test database have):

enter image description here

this ensure when delete customer, delete related orders too.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -