Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How can we multiple delete sql statement used in one sqldatasource1.


sample code is below.
---------------------
SqlDataSource1.DeleteCommand = "delete from csLogin where emp_number =" & EmpNumber
SqlDataSource1.DataBind()
SqlDataSource1.DeleteCommand = "delete from csManpowerAccess where emp_number =" & EmpNumber
SqlDataSource1.DataBind()



pls. correct and help.

Regards,
Ganesh.S
Posted
Updated 22-Jun-11 20:08pm
v2
Comments
[no name] 23-Jun-11 2:03am    
please expalin what exactly you want.

Its better you set the Cascade relationship between both the tables.

So, when once you delete the primary key data it will delete the foreign key rows from the foreign table.
 
Share this answer
 
v3
Comments
Prerak Patel 23-Jun-11 2:17am    
OP is trying to delete from multiple tables.
[no name] 23-Jun-11 2:19am    
yes, i changed my solution.
Create a stored procedure and mention it as DeleteCommand

Otherwise, try On Delete Cascade for new tables or enable cascade delete for existing tables.
 
Share this answer
 
Your best bet is to write a proper datalayer, and have more control over your SQL. You may be able to create one SQL statement that does both things, just put GO between them. But, I don't know how this rubbish works, I never use it, because I prefer well written code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900