2015-08-14 186 views
-1

我無法得到正確的語法爲我的SqlDataSource。我使用的是mySQL數據庫,連接字符串位於web.config文件中。我有這個:需要語法幫助,asp:SqlDataSource

<asp:SqlDataSource ID="sdsEditEvents" runat="server" 
    ConnectionString = <%$ ConnectionStrings["mySQLConnectionString"] %> 
    SelectCommand="SELECT EventID, EventName, EventDate FROM Events ORDER BY EventID" 
    ProviderName="MySql.Data.MySqlClient" 
    onselected="sdsShelfLifeMaster_Selected"> 
</asp:SqlDataSource> 

我的錯誤是「服務器標記不正確。」

任何人都可以把我推向正確的方向嗎?

回答

3

你忘了引用他們。

<asp:SqlDataSource ID="sdsEditEvents" runat="server" 
    ConnectionString ='<%$ ConnectionStrings["mySQLConnectionString"] %>' 
    SelectCommand="SELECT EventID, EventName, EventDate FROM Events ORDER BY EventID" 
    ProviderName="MySql.Data.MySqlClient" 
    onselected="sdsShelfLifeMaster_Selected"> 
</asp:SqlDataSource> 
+0

好的。我還沒有工作,錯誤是一樣的。 –

+0

糟糕。我們在裏面有「quot」。我已經將外部轉換爲單個轉義來轉義 – Xiaoy312

+0

中的內容我將語法更改爲更簡單的格式; ConnectionString =「<%$ ConnectionStrings:mySQLConnectionString%>」它現在正在工作,謝謝! –