简体   繁体   English

sqldatasource selectcommand中的语法

[英]syntax in sqldatasource selectcommand

My SqlDataSource selectcommand is dynamically changed by the String.Format functionality of the Eval one-way databinding syntax. 我的SqlDataSource selectcommand由Eval单向数据绑定语法的String.Format功能动态更改。 It works ok. 可以。 However I need to put together two columns values with a space in the middle (ItemType + '" "' + ItemDescription As ItemInfo) but I can't get the syntax correct as I get the message: "The server tag is not well formed" 但是,我需要将两列值放在一起,中间有一个空格(ItemType +'“”'+ ItemDescription As ItemInfo),但是我收到消息后语法不正确:“服务器标记格式不正确”

Can you help? 你能帮我吗? Many thanks 非常感谢

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand='<%# Eval("TypeID", "SELECT ItemID, ItemType, ItemType + '" "' + ItemDescription As ItemInfo WHERE ItemType = {0}")%>'> </asp:SqlDataSource>

It could be a more general issue with " 可能是“

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ConnectionStrings:conn %>" 
         SelectCommand='<%# Eval(&quot;TypeID&quot;, &quot;SELECT ItemID, ItemType, ItemType + &quot;\" \"&quot; + ItemDescription As ItemInfo WHERE ItemType = {0}&quot;)%>'> 
 </asp:SqlDataSource>

HiI resolved the issue in this way (as advised in How to use Single Quotes in Eval Format String ) HiI以这种方式解决了该问题(如如何在Eval格式字符串中使用单引号中所述

In items.aspx.vb 在items.aspx.vb中

Protected Const SqlQuery As String = "SELECT ItemID, ItemType, ItemType + " + "' '" + " ItemDescription As ItemInfo WHERE ItemType = {0}"

In items.aspx 在items.aspx中

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand='<%# Eval("TypeID", SQLQuery)%>'> </asp:SqlDataSource>

Many thanks 非常感谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM