'Products' 附近有语法错误。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 'Products' 附近有语法错误。源错误:
行 402: Para3.Value = CategoryID;
行 403:
行 404: SqlDataReader result = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection);
行 405: return result;
行 406: }
源文件: c:\Inetpub\wwwroot\Shop\ShopWebSite\App_Code\Classes\Pub.cs 行: 404
源码:
public SqlDataReader spProductsTop(string Top, string OrderBy, string CategoryID)
{
ConnOpen();
SqlCommand1 = new SqlCommand("spProductsTop", SqlConnection1);
SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Para1 = new SqlParameter("@Top", SqlDbType.VarChar, 25);
SqlParameter Para2 = new SqlParameter("@OrderBy", SqlDbType.VarChar, 50);
SqlParameter Para3 = new SqlParameter("@CategoryID", SqlDbType.VarChar, 25); SqlCommand1.Parameters.Add(Para1);
SqlCommand1.Parameters.Add(Para2);
SqlCommand1.Parameters.Add(Para3);
Para1.Value = Top;
Para2.Value = OrderBy;
Para3.Value = CategoryID;
SqlDataReader result = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection);此句有问题不能测试通过???
return result;
}存储过程可以通过测试:
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 'Products' 附近有语法错误。源错误:
行 402: Para3.Value = CategoryID;
行 403:
行 404: SqlDataReader result = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection);
行 405: return result;
行 406: }
源文件: c:\Inetpub\wwwroot\Shop\ShopWebSite\App_Code\Classes\Pub.cs 行: 404
源码:
public SqlDataReader spProductsTop(string Top, string OrderBy, string CategoryID)
{
ConnOpen();
SqlCommand1 = new SqlCommand("spProductsTop", SqlConnection1);
SqlCommand1.CommandType = CommandType.StoredProcedure; SqlParameter Para1 = new SqlParameter("@Top", SqlDbType.VarChar, 25);
SqlParameter Para2 = new SqlParameter("@OrderBy", SqlDbType.VarChar, 50);
SqlParameter Para3 = new SqlParameter("@CategoryID", SqlDbType.VarChar, 25); SqlCommand1.Parameters.Add(Para1);
SqlCommand1.Parameters.Add(Para2);
SqlCommand1.Parameters.Add(Para3);
Para1.Value = Top;
Para2.Value = OrderBy;
Para3.Value = CategoryID;
SqlDataReader result = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection);此句有问题不能测试通过???
return result;
}存储过程可以通过测试:
解决方案 »
- WebBrowser如何抓取微博中评论的内容。。。
- 如何使日期默认不为1900-1-1 0:00:00
- c# 事务处理问题
- 重新编译不起作用怎么办
- c# 用HttpWebRequest实现秒杀时,对方服务器繁忙
- datagridview显示日期字段是出错的问题
- 怎么制作.net的web程序安装包,我的数据库是SqlServer 2005!
- Winform中如何设置datagrid的风格
- 类似QQ中的双击消息记录中的消息,消息就会显示在聊天窗口上?
- 使用MSBCODE9.OCX来打印条码的问题,如何将带有MSBCODE9.OCX控件的窗体内容打印出来?
- 怎样判断线程是否结束?--在线等待
- Select 语句和存储过程的问题
(@top varchar(25),
@orderby varchar(50),
@categoryId varchar(25))
as
set nocount on
declare @ssql varchar(500)
select @sSql='select top'+@top
select @sSQL=@sSql+'o.*,s.Name as CategoryName,'
select @sSQL=@sSql+ 'p.Name as Vendor'
select @sSQL=@sSql+ 'from Products o inner join 'select @sSQL=@sSql+ 'categories s on o.CategoryId=s.Id inner join '
select @sSQL=@sSql+'Customers p on o.VendorId=p.Id'if cast(@CategoryId as int)>=0
begin
select @sSQL=@sSQL +'where o.CategoryID='+@CategoryId
end
if @orderBy <>'DateTimed'
select @sSql=@sSql+'Order by o.'+@Orderby +' desc ,o.DateTimed desc &'
else
select @sSql=@sSql+ 'order by o'+@orderby +'desc'
exec (@sSql)
set nocount offdeclare @cartId varchar(50)SELECT A.ProductID, A.ModelName, A.ModelNumber, B.Quantity,
A.UnitCost, CAST(A.UnitCost * B.Quantity AS money) AS ExtendedAmount
FROM dbo.Products A INNER JOIN
dbo.ShoppingCart B ON A.ProductID = B.ProductID
WHERE (B.CartID = @CartID)
ORDER BY A.ModelName, A.ModelNumber
过程或函数 'spProductsTop' 需要参数 '@top',但未提供该参数。
没有行受影响。
(返回 0 行)
@RETURN_VALUE =
完成 [dbo].[spProductsTop] 运行。
线程 'z2ru7igr0uobi9q [57]' (0x870) 已退出,返回值为 0 (0x0)。
程序“[1104] [SQL] z2ru7igr0uobi9q: z2ru7igr0uobi9q”已退出,返回值为 0 (0x0)。
请问这是??
if @orderBy <>'DateTimed'
select @sSql=@sSql+'Order by o.'+@Orderby +' desc ,o.DateTimed desc &'
else
select @sSql=@sSql+ 'order by o'+@orderby +'desc'
print @sSqlexec (@sSql)
set nocount off
.........Sql2005中显示结果为:消息 201,级别 16,状态 4,过程 spProductsTop,第 0 行
过程或函数 'spProductsTop' 需要参数 '@top',但未提供该参数。(1 行受影响)
过程或函数 'spProductsTop' 需要参数 '@top',但未提供该参数。(1 行受影响)
是不是要添加个@top参数呀?怎么添加啊