473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

string limit

Is there a string limit is C#?

I have a Textbox that I am allowing users to paste into (can be a word
document). But I am finding that I am losing data when I write large files
to my Sql Server database.

The fields is set to text. The data is kept in an object in a "string"
variable when I am moving from asp.net page to page.

One example had the data at 23k, but when I got the data back, it only have
7k in it.

What happened to the rest?

Thanks,

Tom
May 2 '06 #1
8 8291
Tom,

What is the definition of the field? If it is a varchar, then I think
the maximum that it can hold is 8000 characters (approximately).

You would be better off using text or varchar(max) (in the case of SQL
Server 2005) to store your field.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
Is there a string limit is C#?

I have a Textbox that I am allowing users to paste into (can be a word
document). But I am finding that I am losing data when I write large
files to my Sql Server database.

The fields is set to text. The data is kept in an object in a "string"
variable when I am moving from asp.net page to page.

One example had the data at 23k, but when I got the data back, it only
have 7k in it.

What happened to the rest?

Thanks,

Tom

May 2 '06 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eh**************@TK2MSFTNGP03.phx.gbl...
Tom,

What is the definition of the field? If it is a varchar, then I think
the maximum that it can hold is 8000 characters (approximately).
Turns out that was the the problem. I did have it defined as a text field,
but in one of my Stored Procedures, I had it set to varChar(8000). That was
what it originally was, but when I changed it, I missed that SP.

BTW, is there a limit on "string"?

Thanks,

Tom

You would be better off using text or varchar(max) (in the case of SQL
Server 2005) to store your field.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
Is there a string limit is C#?

I have a Textbox that I am allowing users to paste into (can be a word
document). But I am finding that I am losing data when I write large
files to my Sql Server database.

The fields is set to text. The data is kept in an object in a "string"
variable when I am moving from asp.net page to page.

One example had the data at 23k, but when I got the data back, it only
have 7k in it.

What happened to the rest?

Thanks,

Tom


May 2 '06 #3
> BTW, is there a limit on "string"?

AFAIK, yes. The limit is the amount of free and availabe RAM plus the
available allowed size of the swap file on disk minus the size of the used
portion of the swap file...give or a take...

:P

Mythran

May 2 '06 #4
Thanks,

Tom

"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
BTW, is there a limit on "string"?


AFAIK, yes. The limit is the amount of free and availabe RAM plus the
available allowed size of the swap file on disk minus the size of the used
portion of the swap file...give or a take...

:P

Mythran

May 2 '06 #5
This is wrong.

..NET strings are like ole bstrs, they contain an integer specifying their
length ... maximum size is uint.max - some bits (I forget how many which are
used for various flags by the framework itself)

Cheers,

Greg
"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
BTW, is there a limit on "string"?


AFAIK, yes. The limit is the amount of free and availabe RAM plus the
available allowed size of the swap file on disk minus the size of the used
portion of the swap file...give or a take...

:P

Mythran

May 3 '06 #6
also there would be a hard 2gb limit unless you hack up your version of
windows with /3gb in which case it would be 3 :)

Cheers,

Greg
"Mythran" <ki********@hotmail.comREMOVETRAIL> wrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl...
BTW, is there a limit on "string"?


AFAIK, yes. The limit is the amount of free and availabe RAM plus the
available allowed size of the swap file on disk minus the size of the used
portion of the swap file...give or a take...

:P

Mythran

May 3 '06 #7
Greg Young wrote:
also there would be a hard 2gb limit unless you hack up your version of
windows with /3gb in which case it would be 3 :)


Except that I believe there's a limitation that any object in .NET can
be at most 2GB anyway. Besides which, the string.Length property can
only go up to int.MaxValue/2 (because the top 2 bits are used for extra
information) which means a maximum of 1G characters (2GB).

I seem to remember there's something else which knocks it down by a few
characters too (other than the object overhead, of course).

As always with this discussion, it's worth noting that all this means
you'll run into other problems before you run into the limit of string
lengths :)

Jon

May 3 '06 #8
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Greg Young wrote:
also there would be a hard 2gb limit unless you hack up your version of
windows with /3gb in which case it would be 3 :)
Except that I believe there's a limitation that any object in .NET can
be at most 2GB anyway. Besides which, the string.Length property can
only go up to int.MaxValue/2 (because the top 2 bits are used for extra
information) which means a maximum of 1G characters (2GB).

I seem to remember there's something else which knocks it down by a few
characters too (other than the object overhead, of course).

As always with this discussion, it's worth noting that all this means
you'll run into other problems before you run into the limit of string
lengths :)


True.

I would not even come close to these limits. I just wanted to make sure
there wasn't a smaller limit such as 32k or 64k.

Thanks,

Tom
Jon

May 3 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Wade G. Pemberton | last post by:
Can't find it quickly in the reference books.
8
by: Hal Vaughan | last post by:
Is there a maximum length for Javascript program lines? What about strings? Is there a limit on string length? I found some references that said the maximum string length was 256 characters,...
15
by: Andrew Brampton | last post by:
Hi, I'm new to using std classes, but I was wondering how I could do the following efficiently with the string class: Say I had a string with delimited values such as:...
1
by: Alan J. Flavell | last post by:
What are the theoretical and practical limits on the length of a GET query string, currently? Strange to say, I found this rather simple question hard to answer, possibly because of searching...
5
by: Sehboo | last post by:
Hi, Is there any easy way to limit the size of the string? I have Private msDescription As String I want to limit the msDescription to 50 instead of unlimitted.
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
2
by: Daniel | last post by:
c# string size limit? length of string limit?
1
by: Daniel | last post by:
is there any limit to how long of a string SqlDataReader.GetString() can return?
3
by: ipellew | last post by:
Hi; Whats the maximum string length in Javascript. Is it the same across all the browsers? max_s_len = str.length // what the max number of chars we can have is str? Regards
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.