Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2009, 10:10 PM
Authorized User
 
Join Date: Apr 2008
Posts: 26
Thanks: 6
Thanked 0 Times in 0 Posts
Default Blog - SQL Procedure Question

Hello,

When I run the following SQL procedure I get this error:

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

How can I use CONVERT in this procedure?

CREATE PROCEDURE sprocBlogEntryUpdateSingleItem
@id int,
@title nvarchar(200),
@body nvarchar(4000),
@categoryId int,
@datePublished datetime,
@PostedBy varchar(20),
@searchkeywords varchar(200),
@blogsummary varchar(300)

AS
UPDATE
BlogEntry
SET
Title = @title,
Body = @body,
CategoryId = @categoryId,
DatePublished = @datePublished,
PostedBy = @PostedBy,
searchkeywords = @searchkeywords,
blogsummary = @blogsummary

WHERE
Id = @id
GO
 
Old March 16th, 2009, 06:47 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

I assume this is referring to @Body being of type NVARCHAR(4000), but the body column is stored as something like varchar(400). These are incompatible.
The best solution would be to make sure the parameters are of the same type as the database fields, so you don't get any conflicts to begin with.
If you still want to use the nvarchar parameter, you can use convert in Body = @Body as so:
Code:
Body = CONVERT(VARCHAR(400), @Body)
HTH
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrox-Blog: Update Panel Question norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 March 2nd, 2009 09:15 PM
Wrox Blog editor image question norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 February 23rd, 2009 03:40 AM
Wrox Blog - Stored Procedure Update - Count Comments norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 12 February 12th, 2009 01:08 AM
Wrox Blog Question - LinkButton norman001 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 14 February 7th, 2009 03:03 PM
Wrox Blog: Viewing individual blog entries Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 7 May 7th, 2007 12:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.