我现在在如何使我的存储过程SqlDataSource
在aspx页面上工作时遇到麻烦。
这是我的标记:
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand='<%# "EXEC dbo._GetCurrentSession " + Eval("Film_strCode") + " " %>' />
上面的代码虽然没有单引号,但工作正常。但是,当我尝试使用单引号时,它不起作用。标签上会有错误。
看到这个标记:
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand='<%# "EXEC dbo._GetCurrentSession 'some_value_here' " %>' />
请帮助我知道为什么单引号的存储过程在aspx页面上不起作用?我需要使用单引号使我的代码像这样,但是它不起作用。
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand='<%# "EXEC dbo._GetCurrentSession '" + Eval("Film_strCode") + "'" %>' />
有什么办法可以使其工作?请帮我。
如果要从中使用存储过程SqlDataSource
,则应使用此方法-将命令类型定义为StoredProcedure
,并正确设置参数:
<asp:SqlDataSource ID="SqlDataSourceGrantInfo" runat="server"
ConnectionString="<%# _connection.strConnectionString %>"
SelectCommand="dbo._GetCurrentSession"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="SessionValue" Type="Int32" DefaultValue="0" />
</SelectParameters>
</asp:SqlDataSource>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句