I have a TextArea into which the user pastes formatted text (RTF) which was copied from some source (e.g., WordPad). The TextArea’s LimitText parameter is set to 0 (no limit on number of characters inputted). The resultant data is placed in a string and used to update a MS SQL Server database table (using prepared statements) whose associated field is set to NVARCHAR(MAX) data type. I have been using this successfully for some days now without any problems. But today I noticed something strange when I tried it with a “larger” amount of data than usual. The update operation executed without any db errors yet saved nothing … nor did it affect the data that was there in the database previously in any way (when I closed an reopened the program, the same data was there as was before I tried saving the “larger” amount). Playing around with a few things to see what was going on, I found that when the string that contains the TextArea’s content exceeded 2000 characters (RTF overhead and all), the problem occurs. If I back the content down until the string shows something less than 2000 characters, the problem does not exist and the TextArea’s content is saved properly in its entirety. Since the string I’m using to see what the TextArea’s content was DOES contain the entire amount of text it should, regardless of how big the amount is, I know it’s NOT the TextArea limiting the process here.
Something somewhere else seems to be “limiting” the size of what can be saved. I tried TEXT and VARCHAR(MAX) for database table field data types (from what I read researching this, both of which theoretically have greater storage capabilities than NVARCHAR(MAX) … I read somewhere that NVARCHAR(MAX) is actually limited to 4000 characters) but it made no difference.
What could be causing the limit to occur??? 2000 characters ain’t much to choke on!
Here’s the code I’m using to do the save of the TextArea’s contents:
[code] dim ss as string
// save the NOTES section
for iloop As Integer = 0 to Ubound(oContainers)
if oContainerIndex(iloop) = "nc" then
ss = cntNotes(oContainers(iloop)).TANotes.WinRTFDataMBS
Exit For
end if
next
MsgBox (str(ss.Len) + EndOfLine + ss) // USE THIS TO SEE THE SIZE OF THE STRING AND THE CONTENTS IT GOT FROM THE TEXT AREA
// get the caseID of the current record
Dim rs As RecordSet = db.SQLSelect(“SELECT CaseID FROM caseModel WHERE (CaseName=’” + caseName + “’) AND (Revision=’” + caseRevision + “’)”)
Dim cIDnum As Integer = rs.Field(“CaseID”).IntegerValue
rs.close
// save the Notes
Dim sqln As String = _
"UPDATE Notes " + _
" SET NotesData = :nts " + _
" WHERE CaseID = :cID; "
dim vn as Variant = db.Prepare(sqln)
If db.Error Then
// open Modal MsgBox window
taMessage = "UPDATE Model General Record Set PREPARE NOTES Data DB Error: " + db.ErrorMessage
wndModalMsgBox.ShowModal
End If
dim pn as SQLPreparedStatementMBS = vn
pn.BindType(“nts”, SQLPreparedStatementMBS.kTypeString)
pn.BindType(“cID”, SQLPreparedStatementMBS.kTypeLong)
pn.Bind(“nts”, ss)
pn.Bind(“cID”, cIDnum)
pn.SQLExecute
If db.Error Then
// open Modal MsgBox window
taMessage = "UPDATE Model General Record Set SAVE NOTES Data DB Error: " + db.ErrorMessage
wndModalMsgBox.ShowModal
else
db.Commit // Commit the recordset to the database
End If
[/code]