This is a migrated thread and some comments may be shown as answers.

Problem with automatic update of text fields

1 Answer 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
EmpowerIT
Top achievements
Rank 2
EmpowerIT asked on 07 Jan 2008, 06:11 AM
I've set up a basic rad grid using an sqldatasource object. I've specified the parameters and commands to be used:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=MACHOINE1;Initial Catalog=myDB;Persist Security Info=True;User ID=user;Password=password" 
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [JobCodes]" ConflictDetection="CompareAllValues"  
            DeleteCommand="DELETE FROM [JobCodes] WHERE [JobCodeId] = @original_JobCodeId"  
            InsertCommand="INSERT INTO [JobCodes] ([JobId], [CodeId], [QuantityRequired], [QuantityCompleted], [Comment]) VALUES (@JobId, @CodeId, @QuantityRequired, @QuantityCompleted, @Comment)" OldValuesParameterFormatString="original_{0}"  
            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"
            <DeleteParameters> 
                <asp:Parameter Name="original_JobCodeId" Type="Int32" /> 
            </DeleteParameters> 
            <UpdateParameters> 
                <asp:Parameter Name="JobId" Type="Int32" /> 
                <asp:Parameter Name="CodeId" Type="Int32" /> 
                <asp:Parameter Name="QuantityRequired" Type="Decimal" /> 
                <asp:Parameter Name="QuantityCompleted" Type="Decimal" /> 
                <asp:Parameter Name="Comment" Type="String" /> 
                <asp:Parameter Name="original_JobCodeId" Type="Int32" /> 
                <asp:Parameter Name="original_JobId" Type="Int32" /> 
                <asp:Parameter Name="original_CodeId" Type="Int32" /> 
                <asp:Parameter Name="original_QuantityRequired" Type="Decimal" /> 
                <asp:Parameter Name="original_QuantityCompleted" Type="Decimal" /> 
                <asp:Parameter Name="original_Comment" Type="String" /> 
            </UpdateParameters> 
            <InsertParameters> 
                <asp:Parameter Name="JobId" Type="Int32" /> 
                <asp:Parameter Name="CodeId" Type="Int32" /> 
                <asp:Parameter Name="QuantityRequired" Type="Decimal" /> 
                <asp:Parameter Name="QuantityCompleted" Type="Decimal" /> 
                <asp:Parameter Name="Comment" Type="String" /> 
            </InsertParameters> 
        </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



1 Answer, 1 is accepted

Sort by
0
EmpowerIT
Top achievements
Rank 2
answered on 08 Jan 2008, 04:42 AM
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
Tags
Grid
Asked by
EmpowerIT
Top achievements
Rank 2
Answers by
EmpowerIT
Top achievements
Rank 2
Share this question
or