Problem with automatic update of text fields

2 posts, 0 answers
  1. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 07 Jan 2008 Link to this post

    I've set up a basic rad grid using an sqldatasource object. I've specified the parameters and commands to be used:

    1 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=MACHOINE1;Initial Catalog=myDB;Persist Security Info=True;User ID=user;Password=password" 
    2             ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [JobCodes]" ConflictDetection="CompareAllValues"  
    3             DeleteCommand="DELETE FROM [JobCodes] WHERE [JobCodeId] = @original_JobCodeId"  
    4             InsertCommand="INSERT INTO [JobCodes] ([JobId], [CodeId], [QuantityRequired], [QuantityCompleted], [Comment]) VALUES (@JobId, @CodeId, @QuantityRequired, @QuantityCompleted, @Comment)" OldValuesParameterFormatString="original_{0}"  
    5             UpdateCommand="UPDATE [JobCodes] SET [JobId] = @JobId, [CodeId] = @CodeId, [QuantityRequired] = @QuantityRequired, [QuantityCompleted] = @QuantityCompleted, [Comment] = @Comment WHERE [JobCodeId] = @original_JobCodeId AND [JobId] = @original_JobId AND [CodeId] = @original_CodeId AND [QuantityRequired] = @original_QuantityRequired AND [QuantityCompleted] = @original_QuantityCompleted AND [Comment] = @original_Comment"
    6             <DeleteParameters> 
    7                 <asp:Parameter Name="original_JobCodeId" Type="Int32" /> 
    8             </DeleteParameters> 
    9             <UpdateParameters> 
    10                 <asp:Parameter Name="JobId" Type="Int32" /> 
    11                 <asp:Parameter Name="CodeId" Type="Int32" /> 
    12                 <asp:Parameter Name="QuantityRequired" Type="Decimal" /> 
    13                 <asp:Parameter Name="QuantityCompleted" Type="Decimal" /> 
    14                 <asp:Parameter Name="Comment" Type="String" /> 
    15                 <asp:Parameter Name="original_JobCodeId" Type="Int32" /> 
    16                 <asp:Parameter Name="original_JobId" Type="Int32" /> 
    17                 <asp:Parameter Name="original_CodeId" Type="Int32" /> 
    18                 <asp:Parameter Name="original_QuantityRequired" Type="Decimal" /> 
    19                 <asp:Parameter Name="original_QuantityCompleted" Type="Decimal" /> 
    20                 <asp:Parameter Name="original_Comment" Type="String" /> 
    21             </UpdateParameters> 
    22             <InsertParameters> 
    23                 <asp:Parameter Name="JobId" Type="Int32" /> 
    24                 <asp:Parameter Name="CodeId" Type="Int32" /> 
    25                 <asp:Parameter Name="QuantityRequired" Type="Decimal" /> 
    26                 <asp:Parameter Name="QuantityCompleted" Type="Decimal" /> 
    27                 <asp:Parameter Name="Comment" Type="String" /> 
    28             </InsertParameters> 
    29         </asp:SqlDataSource> 

    I've got both the insert and delete commands working correctly. The problem is with the edit.

    When ever I try to save one of the rows i edit i get an sql exception of:

    "The data types text and nvarchar are incompatible in the equal to operator".

    The comment field is set to be of type text in the database. I googled and found some suggestions on trying to set the db type to be nvarchar(MAX) but this didnt help.

    If anyone could tell me how to get this working, it would be much appreciated



  2. EmpowerIT
    EmpowerIT avatar
    117 posts
    Member since:
    Jun 2007

    Posted 07 Jan 2008 Link to this post

    The problem seems to have gone away after I modified the update statements where clause to only include the primary key
    Not sure why this fixed it though
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top