【牛腩新闻】——过程或函数 'news_selectByContent' 需要参数 '@content',但未提供该参数。

最近总是遇到这个问题,在解决他的过程中对牛腩有了进一步的认识,分享我的历程

先看联机帮助的解答:

System.Data.SqlClient.SqlException过程或函数'news_selectByContent' 需要参数 '@content'

当 SQL Server 返回警告或错误时,将生成SqlException 异常。

由此推断数据库中的存储过程有问题,我们来看存储过程:

ALTER PROCEDURE [dbo].[news_selectByContent]

@content varchar(1000)

AS

BEGIN

       selecttop 10 n.id,n.title,n.createTime,c.[name],n.caId from news n

       innerjoin category c on n.caId = c.id

       wheren.content like '%'+@content+'%'

       orderby n.createTime desc

END

改为下面:

ALTER PROCEDURE [dbo].[news_selectByContent]

@content varchar(1000)

AS

BEGIN

       selecttop 10 n.id,n.title,n.createTime,c.[name],n.caId,n.content from news n

       innerjoin category c on n.caId = c.id

       wheren.content like '%'+@content+'%'

       orderby n.createTime desc

END

其实我就在select语句里面插入一个n.content,结果还是报这个错误,真是郁闷,之前类似

这样的问题就是这样解决的啊,于是继续在百度上找解决方案

看到俊哥的总结系列博客,真是厉害,稍后总结

猜你喜欢

转载自blog.csdn.net/yanwenwennihao/article/details/80732117