473,386 Members | 1,819 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,386 software developers and data experts.

When changing to type text from nvarchar, the 255 character limit is maintained?

Hi - I am changing a field from type nvarchar to type text, given that
I need to store strings longer than 255 characters. To do this I
change the data type in SQL Server, then I change the parameter code in
the calling procedure, as per below:

cmd.Parameters.Append(cmd.CreateParameter("@title" , adVarWChar,
adParamInput, 255, title));

becomes:

cmd.Parameters.Append(cmd.CreateParameter("@title" , adLongVarWChar,
adParamInput, 1073741823, title));
However, when I do this, for some reason, the field is still limited to
255 characters - when I try to update the field with 256 characters,
the error 'Application uses a value of the wrong type for the current
operation.' occurs.

Why is this? I've checked that the correct data is contained in the
parameter. When I look at the data in the database, the column in
question shows the content, whereas the next column, which has always
been of type text, shows '<LongText>' - does this mean anything? Do I
need to do something special to convert the column from nvarchar to
text?

Many thanks,
Iain

Jul 23 '05 #1
1 6437
(ip*****@intraspin.com) writes:
Hi - I am changing a field from type nvarchar to type text, given that
I need to store strings longer than 255 characters. To do this I
change the data type in SQL Server, then I change the parameter code in
the calling procedure, as per below:
Well, nvarchar can be up to 4000 characters long, so there is no need
to go to text directly.

And if you are using nvarchar because you need to support Unicode, you
should use ntext, not text.
However, when I do this, for some reason, the field is still limited to
255 characters - when I try to update the field with 256 characters,
the error 'Application uses a value of the wrong type for the current
operation.' occurs.

Why is this? I've checked that the correct data is contained in the
parameter. When I look at the data in the database, the column in
question shows the content, whereas the next column, which has always
been of type text, shows '<LongText>' - does this mean anything? Do I
need to do something special to convert the column from nvarchar to
text?


Judging from what you see in Enterprise Manager, it appears that your
column is still nvarchar(255). You can verify this by running
sp_help on the table in Query Analyzer.

I don't know what could have happened, but I get the feeling that
you used the Table Designer in Enterprise Manager. This tool has
several serious flaws. Run an ALTER TABLE ALTER COLUMN from Query
Analyzer instead.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

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

Similar topics

7
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound...
0
by: CW | last post by:
I get this FieldCount error when I attempt to bind a datagrid with a dataset, not a datareader object. The code snippet is as belows: 'PopulateForm called in Page Load event Private Sub...
0
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
11
by: panic attack | last post by:
Hello everbody, Our system is using Sql Server 2000 on Windows XP / Windows 2000 We have a text file needs to be imported into Sql Server 2000 as a table. But we are facing a problem which is,...
4
by: sandyboy | last post by:
Hi All, I have a database that contains 25 tables. In these tables the character data was stored as nvarchar datatype. Since i am not using any unicode data and the space occupied by nvarchar is...
4
by: Danny | last post by:
Hi All, I have a varchar(255) column for storing text in english and in hebrew. It was a stupid mistake to set the data type to be varchar, because now I need to store text in german and...
12
by: jackson.rayne | last post by:
Hello, I am a javascript newbie and I'm stick at one place. I have a requirement where I will get a sentence in a variable example var v1 ="This is a sentence"
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.