A
DELETE
statement cannot target more than one table.
You will either need to issue two
DELETE
statements:
sqlcommand.CommandText = "DELETE FROM Bank_Detls WHERE Cust_ID = @custid; DELETE FROM Ledgers WHERE Cust_ID = @custid;"
sqlcommand.Parameters.Clear()
sqlcommand.Parameters.AddWithValue("@custid", TxtCustID.Text)
sqlcommand.ExecuteNonQuery()
or change your foreign key constraint to cascade deletes:
Cascading Referential Integrity | Primary and Foreign Key Constraints - SQL Server | Microsoft Docs[
^]