Hi
I have a Table RevinewTable in The Database RevinewDepartment
[S.I.N.O] int Primarykey IsIdentity=yes,Increment=1,seed=1
[NameOfTheApplicant&Address] varchar(20)
[PlotNo.] varchar(20)
[Sy.No] varchar(20)
Village varchar(50)
Mandal varchar(20)
District varchar(20)
RegularisedExtent varchar(20)
[ChallanNo.&Date] varchar(50)
[Endorsement&Date] Date
Like That
I am using SqlDatasource and GridView in My Webform
I configured The SqlDatasource Fallowing way
1.smarttag-->new connection -->(local)-->db is College-->Test Succeded
2.in configure select statement i specified My RevinewTable Table and in Advanced Tab i selected Generate insert update delete and optimistic concurrency
3.I tested My query it works fine
4.I attached this datasource to My gridview
5.I enabled selecting,editing and paging all works fine except edit
when i click on edit it changed to Update and Cancel after entering new details when i click on Update it gives the Fallowing Error
Incorrect syntax near '&'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '&'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Note:
This Process works fine for me when i test with Northwind database with Products table
Please help me
This is the original code
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:DemoRevinew1ConnectionString %>"
DeleteCommand="DELETE FROM [REGULARISEDGOM747] WHERE [S.I.N.O] = @original_column1 AND (([NameOfTheApplicant&Address] = @original_column2) OR ([NameOfTheApplicant&Address] IS NULL AND @original_column2 IS NULL)) AND (([PlotNo.] = @original_column3) OR ([PlotNo.] IS NULL AND @original_column3 IS NULL)) AND (([Sy.No] = @original_column4) OR ([Sy.No] IS NULL AND @original_column4 IS NULL)) AND (([Village] = @original_Village) OR ([Village] IS NULL AND @original_Village IS NULL)) AND (([Mandal] = @original_Mandal) OR ([Mandal] IS NULL AND @original_Mandal IS NULL)) AND (([District] = @original_District) OR ([District] IS NULL AND @original_District IS NULL)) AND (([RegularisedExtent] = @original_RegularisedExtent) OR ([RegularisedExtent] IS NULL AND @original_RegularisedExtent IS NULL)) AND (([ChallanNo.&Date] = @original_column5) OR ([ChallanNo.&Date] IS NULL AND @original_column5 IS NULL)) AND (([Endorsement&Date] = @original_column6) OR ([Endorsement&Date] IS NULL AND @original_column6 IS NULL))"
InsertCommand="INSERT INTO [REGULARISEDGOM747] ([NameOfTheApplicant&Address], [PlotNo.], [Sy.No], [Village], [Mandal], [District], [RegularisedExtent], [ChallanNo.&Date], [Endorsement&Date]) VALUES (@column1, @column2, @column3, @Village, @Mandal, @District, @RegularisedExtent, @column4, @column5)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [REGULARISEDGOM747]"
UpdateCommand="UPDATE [REGULARISEDGOM747] SET [NameOfTheApplicant&Address] = @column1, [PlotNo.] = @column2, [Sy.No] = @column3, [Village] = @Village, [Mandal] = @Mandal, [District] = @District, [RegularisedExtent] = @RegularisedExtent, [ChallanNo.&Date] = @column4, [Endorsement&Date] = @column5 WHERE [S.I.N.O] = @original_column1 AND (([NameOfTheApplicant&Address] = @original_column2) OR ([NameOfTheApplicant&Address] IS NULL AND @original_column2 IS NULL)) AND (([PlotNo.] = @original_column3) OR ([PlotNo.] IS NULL AND @original_column3 IS NULL)) AND (([Sy.No] = @original_column4) OR ([Sy.No] IS NULL AND @original_column4 IS NULL)) AND (([Village] = @original_Village) OR ([Village] IS NULL AND @original_Village IS NULL)) AND (([Mandal] = @original_Mandal) OR ([Mandal] IS NULL AND @original_Mandal IS NULL)) AND (([District] = @original_District) OR ([District] IS NULL AND @original_District IS NULL)) AND (([RegularisedExtent] = @original_RegularisedExtent) OR ([RegularisedExtent] IS NULL AND @original_RegularisedExtent IS NULL)) AND (([ChallanNo.&Date] = @original_column5) OR ([ChallanNo.&Date] IS NULL AND @original_column5 IS NULL)) AND (([Endorsement&Date] = @original_column6) OR ([Endorsement&Date] IS NULL AND @original_column6 IS NULL))">
<asp:Parameter Name="original_column1" Type="Int32" />
<asp:Parameter Name="original_column2" Type="String" />
<asp:Parameter Name="original_column3" Type="String" />
<asp:Parameter Name="original_column4" Type="String" />
<asp:Parameter Name="original_Village" Type="String" />
<asp:Parameter Name="original_Mandal" Type="String" />
<asp:Parameter Name="original_District" Type="String" />
<asp:Parameter Name="original_RegularisedExtent" Type="String" />
<asp:Parameter Name="original_column5" Type="String" />
<asp:Parameter DbType="Date" Name="original_column6" />
<asp:Parameter Name="column1" Type="String" />
<asp:Parameter Name="column2" Type="String" />
<asp:Parameter Name="column3" Type="String" />
<asp:Parameter Name="Village" Type="String" />
<asp:Parameter Name="Mandal" Type="String" />
<asp:Parameter Name="District" Type="String" />
<asp:Parameter Name="RegularisedExtent" Type="String" />
<asp:Parameter Name="column4" Type="String" />
<asp:Parameter DbType="Date" Name="column5" />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="S.I.N.O" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None">
<rowstyle backcolor="#F7F6F3" forecolor="#333333">
<columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="S.I.N.O" HeaderText="S.I.N.O" InsertVisible="False"
ReadOnly="True" SortExpression="S.I.N.O" />
<asp:BoundField DataField="NameOfTheApplicant&Address"
HeaderText="NameOfTheApplicant&Address"
SortExpression="NameOfTheApplicant&Address" />
<asp:BoundField DataField="PlotNo." HeaderText="PlotNo."
SortExpression="PlotNo." />
<asp:BoundField DataField="Sy.No" HeaderText="Sy.No" SortExpression="Sy.No" />
<asp:BoundField DataField="Village" HeaderText="Village"
SortExpression="Village" />
<asp:BoundField DataField="Mandal" HeaderText="Mandal"
SortExpression="Mandal" />
<asp:BoundField DataField="District" HeaderText="District"
SortExpression="District" />
<asp:BoundField DataField="RegularisedExtent" HeaderText="RegularisedExtent"
SortExpression="RegularisedExtent" />
<asp:BoundField DataField="ChallanNo.&Date"
HeaderText="ChallanNo.&Date" SortExpression="ChallanNo.&Date" />
<asp:BoundField DataField="Endorsement&Date"
HeaderText="Endorsement&Date" SortExpression="Endorsement&Date" />
<footerstyle backcolor="#5D7B9D" font-bold="True" forecolor="White">
<pagerstyle backcolor="#284775" forecolor="White" horizontalalign="Center">
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<editrowstyle backcolor="#999999">
<alternatingrowstyle backcolor="White" forecolor="#284775">
[edit]Code moved from comment to question - OriginalGriff[/edit]