如何在.aspx页面中传递查询变量 [英] how can i pass a variable for query in .aspx page
问题描述
我在时收到错误<%= this.sno%>
I got error at <%= this.sno %>
<asp:SqlDataSource ID="MONTHLYPAY" runat="server" ConnectionString="<%$ ConnectionStrings:STUDENTConnectionString %>"
SelectCommand="SELECT A.STU_ID, B.PAY_TYPE, B.PAID_DATE FROM STUDENT AS A INNER JOIN MPINFO AS B ON A.SNO = B.STU_SNO AND A.STU_ID = <%= this.sno %> ORDER BY B.PAID_DATE">
推荐答案
ConnectionStrings:STUDENTConnectionString%>
SelectCommand = SELECT A.STU_ID,B.PAY_TYPE,B.PAID_DATE来自学生作为内部联合MPINFO作为B ON A. SNO = B.STU_SNO和A. STU_ID =<%= this.sno%>订购B.PAID_DATE >
ConnectionStrings:STUDENTConnectionString %>" SelectCommand="SELECT A.STU_ID, B.PAY_TYPE, B.PAID_DATE FROM STUDENT AS A INNER JOIN MPINFO AS B ON A.SNO = B.STU_SNO AND A.STU_ID = <%= this.sno %> ORDER BY B.PAID_DATE">
您可以尝试如下。
You can try like below.
<asp:SqlDataSource ID="ProductsFilteredByPriceDataSource" runat="server"
ConnectionString="<%
ConnectionStrings:NORTHWNDConnectionString %>
SelectCommand =
SELECT ProductName,UnitPrice
FROM Products WHERE UnitPrice< = @MaximumPrice >
< SelectParameters >
< asp:ControlParameter ControlID = MaxPrice 名称 = MaximumPrice
PropertyName = 文字 / >
< / SelectParameters >
< / asp:SqlDataSource >
ConnectionStrings:NORTHWNDConnectionString %>" SelectCommand= "SELECT ProductName, UnitPrice FROM Products WHERE UnitPrice <= @MaximumPrice"> <SelectParameters> <asp:ControlParameter ControlID="MaxPrice" Name="MaximumPrice" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource>
更多信息:
对SqlDataSource使用参数化查询
http://www.asp.net/web-forms/tutorials/data-access/accessing-the-database-directly-from-an-aspnet-page/using-参数化查询与sqldatasource-cs [ ^ ]
SOF
http://stackoverflow.com/questions/5853660/using-variables-in-sql-queries-in -asp-net-c [ ^ ]
我希望这会对你有所帮助。
For more info :
Using Parameterized Queries with the SqlDataSource
http://www.asp.net/web-forms/tutorials/data-access/accessing-the-database-directly-from-an-aspnet-page/using-parameterized-queries-with-the-sqldatasource-cs[^]
SOF
http://stackoverflow.com/questions/5853660/using-variables-in-sql-queries-in-asp-net-c[^]
I hope this will help to you.
这篇关于如何在.aspx页面中传递查询变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!