SQL数据源不显示任何记录 [英] SQL DataSource doesn't show any record
本文介绍了SQL数据源不显示任何记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的SP:
this is my SP:
ALTER proc [dbo].[autherlist]
@l nvarchar(1)=''
as
IF @l = ''
BEGIN
SELECT [author_id], [F-name], [L-name]FROM [authors] ORDER BY [L-name]
end
else
begin
SELECT [author_id], [F-name], [L-name]FROM [authors] where [L-letter] = @l ORDER BY [L-name]
end
这是我的数据源:
and this my datasource:
<asp:SqlDataSource ID="ds" runat="server"
ConnectionString="<%$ ConnectionStrings:ariaquoteConnectionString %>"
SelectCommand="autherlist" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:RouteParameter DefaultValue="" Name="l" RouteKey="letter" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
问题是这样的:SP在sql管理器中执行良好,并且使用ado.net,但是使用数据源却没有记录!
问题出在哪里?
problem is this: SP execute well in sql manager, and with ado.net but with datasource show no record!
where is the problem?
推荐答案
ConnectionStrings:ariaquoteConnectionString %> " SelectCommand =" autherlist" SelectCommandType StoredProcedure" < SelectParameters > < asp:RouteParameter 默认值 =" 名称 l" RouteKey =" 字母" 类型 字符串" / > < /SelectParameters > < /asp:SqlDataSource >
ConnectionStrings:ariaquoteConnectionString %>" SelectCommand="autherlist" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:RouteParameter DefaultValue="" Name="l" RouteKey="letter" Type="String" /> </SelectParameters> </asp:SqlDataSource>
问题是这样的:SP在sql管理器中执行良好,并且使用ado.net,但是使用数据源却没有记录!
问题出在哪里?
problem is this: SP execute well in sql manager, and with ado.net but with datasource show no record!
where is the problem?
在数据源上设置
CancelSelectOnNullParameter="false"
.默认情况下,如果您不指定参数,即使SQL SP可以使用该参数,也不会执行.
on your datasource. By default, if you do not specify a parameter, even though the SQL SP is OK with that, it will not execute.
这篇关于SQL数据源不显示任何记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文