Multi-Line TextBox writting to Sql Server

J

John Carnahan

I have a problem writing the text from a multi-line textbox to the Sql
Server db.
If the user sends a vbcrlf (enter key) in the middle of the entered text,
the text gets
truncated at the vbcrlf when writting the data to the database. The text
could get rather long.


The dataset has all of the text (including the vbcrlf), but the resulting
table field in the database only ends up with the portion of text before the
vbcrlf.

I'm use a sql dataadapter with a parameter for the insert and update
commands
SqlParameter("@Plan2", System.Data.SqlDbType.NVarChar, 1000, "Plan2"))

and the table is nvarchar(1000). The typed dataset xml shows as a string.

<xs:element name="Plan2" type="xs:string" minOccurs="0" />

Do I need to strip out the Vbcrlf from the datset field before issuing the
update? or is there something else I could do?

I'm sure the users will hit the Enter Key in the textbox, so what ever I do
needs to be behind the scenes.

Thanks,

John
 
W

William F. Robertson, Jr.

I apologize if this insults your intelligence.

Are you trying to look at the table through enterprise manager. If so, then
it will only show you one line at a time, you will have to scroll down the
cell to see the rest.

If you look at it through query analyzer, it will show all the data in one
line with extra spaces.

HTH,

bill
 
J

John Carnahan

You didn't insult my intelligence... I'm thinking I don't have any to
insult!
Actually, I was querying the table after the insert, and the data was
truncated. I did a little routine that strips out the vbcrlf's
and it works ok now. I'm sure there is a better solution to this, but it
seems to work. I used a StringReader to readLine() the
string into a new string, and then stuffed that into the dataset before
saving it to the database. The readLine strips out the vbcrlf's.
If you have a better way to do this, please shout.
Thanks,
John
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top