AspnetPage 用存储过程分页 提示未找到存储过程

Kevin_xun 2010-11-05 09:51:13
AspNetPage用存储过程分页但是提示找不到存储过程(数据库中有),下面是代码:
P_Table_Count、P_Tabel_List这两个是存储过程
能找到P_Table_Count,P_Table_List这里就跳异常了

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindData();
}
}

protected void BindData()
{
int totalOrders = (int)SqlHelp.ExecuteScalar(CommandType.StoredProcedure,"P_Table_Count",
new SqlParameter("@tablename","SXWY_B_Stocks"),
new SqlParameter("@where",sSql),
new SqlParameter("@cell","Id"));
AspNetPager1.RecordCount = totalOrders;

repeater.DataSource = SqlHelp.ExecuteReader(CommandType.StoredProcedure, "P_Tabel_List",
new SqlParameter("@startIndex", AspNetPager1.StartRecordIndex),
new SqlParameter("@endIndex", AspNetPager1.StartRecordIndex + AspNetPager1.PageSize - 1),
new SqlParameter("@where", sSql),
new SqlParameter("@topnum", "0"),
new SqlParameter("@tablename", "SXWY_B_Stocks"),
new SqlParameter("@cell", "Id"),
new SqlParameter("@OrderWay", "desc"));
repeater.DataBind();
}

protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
BindData();
}


执行P_Table_List这个存储过程就跳到下面方法里的异常,提示未找到存储过程

public static SqlDataReader ExecuteReader(CommandType cmdType, string cmdText, params SqlParameter[] cmdParms)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(ConString);

// we use a try/catch here because if the method throws an exception we want to
// close the connection throw code, because no datareader will exist, hence the
// commandBehaviour.CloseConnection will not work
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, cmdParms);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
return rdr;
}
catch
{
conn.Close();
throw;//跳到这里了
}
}
...全文
105 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
linsx1987 2010-11-05
  • 打赏
  • 举报
回复
"P_Table_Count"== [dbo].[P_Table_List]????????

刚发错了~~
zuoming120 2010-11-05
  • 打赏
  • 举报
回复
你用这个控件了,还用存储过程?,真是有才,
linsx1987 2010-11-05
  • 打赏
  • 举报
回复
"P_Tabel_List" == [dbo].[P_Table_List]????????
hua_lanyu 2010-11-05
  • 打赏
  • 举报
回复
怎么这么麻烦啊,看不懂,学习!!!
lspzengjing1989 2010-11-05
  • 打赏
  • 举报
回复
你自己在T-SQL里面传参执行下
Kevin_xun 2010-11-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lspzengjing1989 的回复:]
引用 1 楼 qingfeng_wu 的回复:

那应该是你那个地方传参数错了。

先把存储过程到了T-SQL里执行下
[/Quote]

ALTER PROCEDURE [dbo].[P_Table_List]
(@startIndex INT,
@endIndex INT,
@where varchar(2000),
@topnum int,
@tablename varchar(50),
@cell varchar(20)
)
AS
begin

if @topnum<>0

exec ('SELECT top '+@topnum+' * from
(SELECT ROW_NUMBER() OVER (order by '+@cell+' desc) as Row,* from '+@tablename+' '+@where+') as orderList
WHERE Row between '+@startIndex+' and '+@endIndex+'')

else
exec ('SELECT * from
(SELECT ROW_NUMBER() OVER (order by '+@cell+' desc) as Row,* from '+@tablename+' '+@where+') as orderList
WHERE Row between '+@startIndex+' and '+@endIndex+'')

end

你看看这个存储过程有错吗
lspzengjing1989 2010-11-05
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 qingfeng_wu 的回复:]

那应该是你那个地方传参数错了。
[/Quote]
先把存储过程到了T-SQL里执行下
吴青峰 2010-11-05
  • 打赏
  • 举报
回复
那应该是你那个地方传参数错了。

62,271

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧