簡體   English   中英

MySQL 6 與企業庫數據的連接 5

[英]MySQL 6 connection with Enterprise Library Data 5

構建一個簡單的 asp.net web 應用程序只是為了測試東西(顯然會在為生產站點構建任何東西之前重構),我正在嘗試使用最新版本的 Enterprise Library 數據庫連接到 Z81C3B080DAD537DE7E10E0987A4BF52,am錯誤:“MySqlClientFactory 類型不包含 ConfigurationElementTypeAttribute。”

我經歷了幾種不同的 forms 嘗試設置配置,並根據我發現的所有內容,將其提煉成:在我的 web.config 中,我得到了這個:

<configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<dataConfiguration defaultDatabase="MyDB">
<providerMappings>
  <add name="MySql.Data.MySqlClient" databaseType="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,Version=6.3.6,Culture=neutral,PublicKeyToken=c5687fc88969c44d"/>
</providerMappings>
</dataConfiguration>
<connectionStrings>
     <add name="MyDB" connectionString="Server=localhost;Database=MyDB;Uid=root;Pwd=****;"
     providerName="MySql.Data.MySqlClient"/>
</connectionStrings>

在我的 default.aspx 頁面中,我得到了這個:

protected void Page_Load(object sender, EventArgs e)
{
    string sql = "select * from users";
    Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>("MyDB");

    var reader = db.ExecuteReader(CommandType.Text, sql);
    while (reader.NextResult())
    {
        Response.Write(reader["userName"] + "<br />");
    }
}

所以,非常簡單......但同樣,我得到的錯誤是:“MySqlClientFactory 類型不包含 ConfigurationElementTypeAttribute。”

我找不到任何參考... MSDN 並沒有說太多關於該屬性的內容,它所說的我似乎與我正在做的事情無關...任何幫助將不勝感激.

謝謝!

EntLib 不支持開箱即用的 MySql。 EntLibContrib 有一個合適的MySql Data Provider 然而,發布的版本針對的是 EntLib4.1。 我可以看到 v5.0 的移植工作正在進行中,但數據訪問塊似乎還沒有完成。 您可能需要自己移植。

您使用的工廠似乎沒有啟用 EntLib。 您可以在Enterprise Library Extensibility Hands-on Labs中找到對 ConfigurationElementTypeAttribute 的良好處理以及有關如何擴展 EntLib 的其他指南。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM