How to deal with 'text' columns in ADO.NET

P

Paul Bradshaw

From what I can tell, when I "fill" a DataTable with a table that contains 'text' columns, I have no way of distinguishing these columns from regular nvarchar(x) columns. Does it truncate the values returned to 8000 characters? Or is the full text loaded?

My application is to generate a static T-SQL script that will populate that table. Because I can't seem to find a way to tell if an underlying column is 'text' or not, I can't figure out a way to generate the proper SQL script to fill the column and properly copy the row.

Can anyone help?

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
R

Robbe Morris [C# MVP]

The full text is loaded. I regularly load text and ntext columns
in DataTables and have never seen it truncate.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
 
P

Paul Bradshaw

The problem is, I'm concerned about the other half ... translating the data into a textual T-SQL statement that can be executed to successfully load the data.

If I just dump the data out into an INSERT statement, treating the text like any other nvarchar column, will it work just fine even if the text is tens of thousands of chracters? (as long as I escape any embedded single-quote of course)

My initial experiements seem to show this working, but every single bit of documentation seems to imply this shouldn't work. Is this just a case of documentation being unclear or incorrect? If I use osql to issue such an INSERT command (trying to insert 40,000 characters right there in the body of the INSERT statement as if it were any other string) is that guarenteed to work just fine on both SQL2k and SQL2005?


EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 

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

Top