?
Solved

Can't pass ntext getting conversion error

Posted on 2008-10-02
3
Medium Priority
?
806 Views
Last Modified: 2013-11-07
I'm using a DataAdapter and am trying to pass through a parameter which is accepted as ntext by the stored procedure

The value I have in the page is a string, which I know is converted to an ntext in C# when it exceeds the 4000 limit. In this case that will happen

adding paramter as such

da.SelectCommand.Parameters.Add("@purchases", SqlDbType.NText);
da.SelectCommand.Parameters["@purchases"].Value = purchases;

When it gets to a value for "purchases" that has been converted to ntext I get the following error:

SqlException: Implicit conversion from data type ntext to varchar is not allowed. Use the CONVERT function to run this query

But I'm explicitly trying to pass it as ntext as the sqldbtype, right? How do I convert this string variable "purchases" into the appropriate value

thanks in advance
0
Comment
Question by:animated405
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 22629634
change your select command from:
    SELECT * FROM YOURTABLE WHERE YourNTextField = @purchases
To:
    SELECT * FROM YOURTABLE WHERE YourNTextField = CONVERT(NTEXT, @purchases)

then you ca use:

da.SelectCommand.Parameters.Add("@purchases", SqlDbType.Varchar);
da.SelectCommand.Parameters["@purchases"].Value = purchases;
0
 

Author Comment

by:animated405
ID: 22688111
yeah tried it but it didn't work, which I don't get. I need to step through the code just got busy on other stuff right after I wrote this. I will check it out soon and provide a response. Not trying to chince out...
0
 

Author Comment

by:animated405
ID: 22745518
i am apparently never going to get back to this. thanks again
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question