2017-07-08 150 views
0

我開發了一個網站,其中使用了ASP.NET和VB.NET作爲後端編程語言和MySQL數據庫。我已經使用ASP.NET和MySQL數據庫連接器在本地計算機上運行該網站,並且它工作正常。 web.config文件的代碼下面給出:MySQL數據庫和ASP.NET全局連接

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please 
    visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
--> 
<configuration> 
    <system.web> 
     <trust level="Medium"/> 
     <customErrors mode="Off" defaultRedirect="Home.aspx"/> 
     <compilation debug="true" strict="false" explicit="true" 
        targetFramework="4.0"> 
      <assemblies> 
       <add assembly="MySql.Data, Version=6.9.9.0, Culture=neutral, 
        PublicKeyToken=C5687FC88969C44D"/> 
      </assemblies> 
     </compilation> 
    </system.web> 
</configuration> 

但現在我已上載該網站和數據庫的全局服務器上,並把我的代碼中的全局數據庫連接。現在web.config文件中的代碼是

<?xml version="1.0"?> 
<!-- 
    For more information on how to configure your ASP.NET application, please 
    visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
--> 
<configuration> 
    <connectionStrings> 
     <add name="myConnectionString" connectionString= "Server=globalservername; 
      Database=databasename; Uid=userid; Pwd=passwd;" 
      providerName="MySql.Data.MySqlClient" /> 
    </connectionStrings> 
    <system.web> 
     <trust level="Medium"/> 
     <customErrors mode="Off" defaultRedirect="Home.aspx"/> 
     <compilation debug="true" strict="false" explicit="true" 
        targetFramework="4.0"> 
     </compilation> 
    </system.web> 
</configuration> 

當我打開任何頁面則顯示以下錯誤

編譯器錯誤信息:BC30002:類型「的MySqlConnection」沒有定義。

在這條線是在我的項目(連接字符串)的每一個Visual Basic文件

Dim SQLConnection As New MySqlConnection("Server=globalservername; 
Database=databasename; Uid=userid; Pwd=passwd;") 

我應該添加或刪除在web.config文件中刪除此錯誤?

+0

另請參閱:https://stackoverflow.com/questions/29094224/type-mysqlconnection-is-not-defined – Palindromer

回答

0

您可能會在生產環境中缺少所需的DLL文件,MySQL.Data。你可以使用NuGet包* MySQL.Data *然後構建和部署。

或者,您可以將MySQL.Data DLL文件放入bin文件夾並進行部署。

+0

thanx它的工作原理 – Deepak

0

首先要做的事:

Mysqlopen("db") 

它應該工作。如果沒有,那麼確保你有VB 2005.它不適用於Visual Basic 6.0。如果這不起作用,那麼您可以將SQL作爲單獨的進程運行,並使用Visual Basic來調用它。