insert into/update table in db with long text

  • Thread starter Alexander Widera
  • Start date
A

Alexander Widera

Hi,

i connect to a ms sql2000server via SqlConnection.
if i make an SqlCommand "INSERT INTO mytable (mytext) VALUES (@mytext)" (or
i make an update),
and i pass the parameter @mytext a simple string, i get NO ERROR and the
database has an new empty row instead of the string which should be there.
mytext is type of "text".
I found out, that this effect only happens if the text is longer than around
900 words... if the text is shorter it works correct.

Does somebody know this problem?

Thanks a lot.
Alex
 
S

S. Justin Gengo [MCP]

Alex,

In SQL Server char, varchar, nvarchar, etc. fields all have a maximum number
of characters that may be set. This amount may be changed for the field in
question but ther is a limit. If you need to store more characters than the
maximum allowed in the plain text fields then an "ntext" field may be used
to store much more information, but ntext does not store the text the same
way in the field and requires conversion going in and out making it a bit
more difficult a field to work with.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Alexander Widera"
 
A

Alexander Widera

I think text stores (2 ^ 31)(-1) characters ... and ntext "only" (2^30)(-1)
characters...
normally text would be "enough" ... but it doesn't store it.
I tried also ntext ... there is the same problem.

the error is still existing.
 
S

S. Justin Gengo [MCP]

Alexander,

If those fields aren't long enough you will either have to encode and store
the text in a blob field (Search for storing pictures in a SQL Server
database that uses blob fields and storing a text file would be similar), or
you'll need to split the text up into pieces, or another alternative would
be to store the text in a regular file and then store a reference to said
file in the database.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Alexander Widera"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top