473,657 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Crea teParameter("@t itle", adVarWChar,
adParamInput, 255, title));

becomes:

cmd.Parameters. Append(cmd.Crea teParameter("@t itle", 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 6494
(ip*****@intras pin.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****@sommarsk og.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
12067
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 to know this number after the first FETCH, isn't it? On a side note, why queries using LIMIT are SO terribly slow, compared to cursors and sometimes even ones without LIMIT? Shouldn't LIMIT be internally implemented using cursor mechanism then?...
0
1572
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 PopulateForm(ByVal MyOrderDetails As MyChannel.OrderDetails) Me.lblOrderID.Text = CStr(MyOrderDetails.OrderID)
0
683
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. Aparently, when I select a person, it's not selecting anyone and returning this error. Here's the full error: Description: An unhandled exception occurred during the execution of the
11
3425
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 difference between data type 'CHAR' and 'TEXT'? When do you use 'VAR' in your datatype word? e.g. VARCHAR ?
11
2907
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, Sql Server claims that it has a character size limit ( which is 8060 ) so it cant procceed the import operation if the text file has a record bigger then 8060. The records , in the text file, have a size bigger then 8060. So we wont be able to...
4
1576
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 more , i want to change the datatype from nvarchar to varchar. I cannot do one by one since there are 25 tables and each table has atleast 10 columns of datatype nvarchar. How can i change the datatype from nvarchar to varchar in all the tables....
4
4092
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 francais too. Question: Is it safe to change the data type from varchar to nvarchar, without damaging the data that's already present? (I have more than 1000000 records stored...)
12
3980
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
6960
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 of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.