简体   繁体   English

sql数据源曾经在Visual Studio 2005中工作,但现在不在2010年工作

[英]sql data source used to work in visual studio 2005 but not now in 2010

I have a sql data source declared on an aspx page which worked fine in Visual Studio 2005, but since migrating to Visual Studio 2010 the DefaultValue parameter is not evaluating the specified function and or the value passed in from a property in the code behind. 我在aspx页面上声明了一个sql数据源,该数据在Visual Studio 2005中可以正常工作,但是自从迁移到Visual Studio 2010以来,DefaultValue参数未评估指定的函数和/或从后面代码中的属性传递的值。 When checked in SQL Query Analyser the code passed to the database is just using the DafaultValue as a literal string. 在SQL Query Analyzer中检查时,传递给数据库的代码仅使用DafaultValue作为文字字符串。 How can I rectify this? 我该如何纠正?

<!--sql data source-->
<asp:SqlDataSource id="sdsltblCNS_SECOND_REF" runat="server" ConnectionString="<%$ ConnectionStrings:SCRConnectionString %>"
    SelectCommand="Sel_CNS_SECOND_REFByCASite" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:Parameter DefaultValue='<%= Common.GetSiteName(Me.SelectedSite) %>' Name="CASite" ConvertEmptyStringToNull="true" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

' SelectedSite property
Public ReadOnly Property SelectedSite As Site
    Get
        If ViewState("SelectedSite") Is Nothing Then
            ViewState("SelectedSite") = Common.GetSiteByCareID(CareID)
        End If
        Return ViewState("SelectedSite")
    End Get
End Property

-- query analyser
exec Sel_CNS_SECOND_REFByCASite @CASite=N'<%= Common.GetSiteName(Me.SelectedSite) %>'

也许我说的是显而易见的内容,并且遗漏了更深的内容(这已经是漫长的一天),但是您不应该使用引号而不是单个刻度,例如:

<asp:Parameter DefaultValue="<%= Common.GetSiteName(Me.SelectedSite) %>" Name="CASite" ConvertEmptyStringToNull="true" Type="String" />

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

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