Invalid syntax next to 'nvarchar' in ASP.NET Gridview update

A very simple question, but the whole answer that I read via the Internet does not apply.

I am trying to do an update in an ASP.NET Gridview, but when I click on the update, I get this error:

Invalid syntax next to "nvarchar". The scalar variable @intID must be declared.

Here is my data source. I assume that the problem comes from here, but I do not see where ...

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connexionDev %>"  
        DeleteCommand="DELETE FROM [tbl_Bug] WHERE intID = @intID" 
        SelectCommand="SELECT [intID],[strTitre],[strDescription],[intStatus_FK],[intType_FK],[intSeriousness_FK] FROM [tbl_Bug]"  
        UpdateCommand="UPDATE [tbl_Bug] SET [strTitre] = @strTitre ,[strDescription] = @strDescription ,[intStatus_FK] = @intStatus_FK ,[intType_FK] = @intType_FK ,[intSeriousness_FK] = @intSeriousness_FK WHERE [intID] = @intID">   
        <DeleteParameters>   
            <asp:Parameter Name="intID" Type="Int32" />   
        </DeleteParameters>   
        <UpdateParameters>
            <asp:Parameter Name="intID" Type="Int32" />
            <asp:Parameter Name="strTitre" Type="String" />   
            <asp:Parameter Name="strDescription" Type="String" />
            <asp:Parameter Name="intStatus_FK" Type="Int32" />   
            <asp:Parameter Name="intType_FK" Type="Int32" />
            <asp:Parameter Name="intSeriousness_FK" Type="Int32" />   
        </UpdateParameters>     
    </asp:SqlDataSource>

Thanks for your help in advance!

EDIT - EDIT - EDIT

Well, I wanted to use SQL Profiler, but it seems that it is not in my version (SQL Server 2008 Express), so I tried another sql profiler, which is open source, but I never understood how it works, and it always crash ..

, ?

+3
5

, GridView, , .

: Text='<%# Bind("myValue") %>'

: Text='<%# Bind("[myValue]") %>'

!:) !

!

+4

SQL Profiler , SQL, - , , SQL Server.

+1

SqlDataSource.Updating - , , . DbCommand , SqlDataSourceCommandEventArgs, Command. , ( DbCommand.Parameters) .

0

, <SelectParameters>...</SelectParameters>, .

0

, / - - .

If you look at the SQL server monitor and look at the generated SQL code for updates, it is corrupted due to spaces in the column names.

0
source

Source: https://habr.com/ru/post/1715040/


All Articles