ASP.NET SqlDataSource中的Sql命令 [英] Sql command in ASP.NET SqlDataSource

查看:66
本文介绍了ASP.NET SqlDataSource中的Sql命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用asp.net源代码编写此代码.但是我需要在某种情况下使用select命令.那么我该如何声明条件.这是我写的:

I am writing this code in asp.net source code. But I need select command in a condition. So how can I declare where condition. This is what I wrote:

Select * from Table where Id=<%=Label1.Text%>


但显示错误-<附近的语法不正确.


but it shows a error - incorrect syntax near <.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=com1;Initial Catalog=EmpData;Integrated Security=True" >


SelectCommand="SELECT * from Table"
DataSourceMode="DataSet" ProviderName="System.Data.SqlClient"<asp:SqlDataSource>



请帮助我在select命令中声明where子句.

在此先谢谢您.



Please help me declaring where clause in select command.

Thanks in advance.

推荐答案

尝试此链接

通过SqlDataSource控件使用参数 [
try this link

Using Parameters With SqlDataSource Controls[^]


从<中删除"=" %= Label1
remove the ''='' from <%=Label1


尝试这个,我已经用过了.
try this one, i already used this.
<asp:SqlDataSource ID="dsDetailDataSource1" runat="server" ConnectionString="<%


这篇关于ASP.NET SqlDataSource中的Sql命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆