user3676876 user3676876 - 3 months ago 7x
HTML Question

Syntax error in gridview delete option

I added delete to my gridview and I get syntax error I don't understand
here is my code:

DeleteCommand = "DELETE FROM [Games]
WHERE [Team1] = @Team1, [Team2] = @Team2"

InsertCommand = "INSERT INTO [Games] ([Team1], [Team2], [GameType], [Time]) VALUES (@Team1, @Team2, @GameType, @Time)"

UpdateCommand = "UPDATE [Games] SET [Team1] = @Team1, [Team2] = @Team2, [GameType] = @GameType, [Time] = @Time WHERE [Team1] = @Team1">

<asp:Parameter Name="Team1" Type="string" />
<asp:Parameter Name="Team2" Type="string" />
<asp:Parameter Name="GameType" Type="string" />

Thank you

DELETE FROM [Games] WHERE [Team1] = @Team1,[Team2]=@Team2

Should be

DELETE FROM [Games] WHERE [Team1] = @Team1 AND [Team2]=@Team2

Notice the "And" between the conditions.

FYI - Posting the error message in future will stop you getting down votes but anyway..