1

I am using asp.net sqldatasource connected to formview which has update parameter defined as string like such:

<UpdateParameters>
<asp:Parameter Name="C"   Type="String" />
</UpdateParameters>

When I exceed 4000 characters I get "String truncation: max=4000..." error. I am updating to SQL Compact Edition 4.0 and field is ntext. I was able to put more than 4000 characters usign visual studio interface the problem seems not to be with the database field type or size.

Changing the parameter to:

<asp:Parameter Name="C"   Type="String" size="5000" /> 

did not help. If I do this I get no errors but no more than 4000 characters get updated.

What could be limiting the update character size?

baktay
  • 11
  • 2
  • Take a look at [this answer](http://stackoverflow.com/a/11366034/728795), you might need to opt to nvarchar(max) instead of ntext – Andrei Feb 18 '15 at 18:33
  • Thanks but I tried that. ntext is fine. The problem is not with the database type as I can insert more data via sql query in Visual Studio, for example. The problem seems to be with the sqldataadapter update paramater size limitations – baktay Mar 07 '15 at 11:34

1 Answers1

0

I ended up moving database update at code behind

   Using connection As New SqlCeConnection(connstr)
        Dim nonquerycommand As SqlCeCommand = connection.CreateCommand()

        nonquerycommand.Parameters.Add("@c", SqlDbType.NText).Value = TheData

        connection.Open()
        nonquerycommand.CommandText = queryString
        nonquerycommand.ExecuteNonQuery()
        connection.Dispose()
    End Using

I still wonder why I hit the 4000 character limit when I use SqlDatasource with asp:Parameter tag. Looking at the code, adding SqlDbType.NText parameter may be the issue. I could not add this on aspx page to the asp:Parameter tag.

I wish I could handle this on aspx page with SqlDataSource Update Parameters. But it wont work for updating more than 4000 Characters.

I have to make revisions on a number of projects so If there is an anwer to my initial question it will save me time. Although codebehind solution works for more than 4000 characters, I won't have to change for each project if sqldatasource in aspx page handles 4000+ characters - so help is appreciated.

baktay
  • 11
  • 2