Reputation: 359
So I have two tables:
and I want to delete a record from Kategoria-Adres
, where the ID_Adres
in Kategoria-Adres
is the same like ID_Adres
in Adres
when I select an item from a listbox.
string delete_string1 = "DELETE FROM Kategoria-Adres INNER JOIN Adres ON
Kategoria-Adres.ID_Adres = Adres.ID_Adres WHERE Adres.Adres LIKE "
+ listBox1_Selected_Item + " AND Adres.ID_Adres = Kategoria-Adres.ID_Adres";
I've tried this, but it doesn't work for me.
Upvotes: 0
Views: 401
Reputation: 120
It looks like the problem is in your query.
Something like this should work:
DELETE FROM Kategoria-Adres
INNER JOIN [Adres] ON [Kategoria-Adres].[ID_Adres] = [Adres].[ID_Adres]
WHERE [Adres].[Adres] LIKE '%" + listbox1.SelectedValue + "%' AND [Adres].[ID_Adres] = [Kategoria-Adres].[ID_Adres]
As a side note, you should include your C# and ADO.Net code in the future incase you're missing something from there, and the error code.
Upvotes: 1