I am trying to perform UPDATE action in Gridview(ASP.net). I have created a AccessDataSource and included all the queries in it. Delete, Select queries work well but not the UPDATE
I get the error “Syntax error in Update statement“. My query is
UPDATE RateCenters SET RateCenterName = @RateCenterName,
State/Province = @State/Province, Quantity/Threshold = @Quantity/Threshold
WHERE RateCenterID = @RateCenterID
I realized from a site that ‘[]’ should be used if the query has special characters like “/”
So I have changed the query to
UPDATE RateCenters SET [RateCenterName] = [RateCenterName], [State/Province] = [State/Province], [Quantity/Threshold] = [Quantity/Threshold] WHERE RateCenterID = RateCenterID.
Now I am not getting any error on UPDATE action but the data is not getting updated
This is my html code
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/db1.mdb" SelectCommand="SELECT * FROM RateCenters"
DeleteCommand="DELETE FROM RateCenters WHERE RateCenterID = @RateCenterID"
InsertCommand="INSERT INTO RateCenters ([RateCenterID], [RateCenterName], [State/Province], [Quantity/Threshold]) VALUES ([RateCenterID], [RateCenterName], [State/Province], [Quantity/Threshold])"
UpdateCommand="UPDATE RateCenters SET RateCenterName = @RateCenterName, State[/]Province = @State[/]Province, Quantity[/]Threshold = Quantity[/]Threshold WHERE RateCenterID = @RateCenterID">
</asp:AccessDataSource>
Kindly let me know the problem
Thanks
Arjun
a quick write up
UpdateCommand=”UPDATE RateCenters SET RateCenterName = @RateCenterName, [State/Province] = @State, [Quantity/Threshold] = @Quantity WHERE RateCenterID = @RateCenterID”>