问题
I have created a website that uses a MySQL
database, but when i put it online, it doesn't work anymore. in my class connection.vb
that i use for my connection to my database i get the following warning:
Namespace or type specified in the Imports 'MySql.Data.MySqlClient' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
and it says that the type mysqlconnection
is not defined.
this is my code:
Imports Microsoft.VisualBasic
Imports MySql.Data.MySqlClient
Public Class connection
Public Shared cn As New MySqlConnection(ConfigurationManager.ConnectionStrings("cnDatabase").ConnectionString)
End Class
If i do the same imports statement in an other vb
file such as e.g index.aspx.vb it gives me no error
Does anybody know what is wrong?
Thanks in advance.
回答1:
Make sure to embed the dll
files for Mysql
. Check the dependencies of your project, resources paths must be different from your local configuration.
I think you can find what you're looking for on this website
回答2:
try this, You have to remove old reference of that file add new reference as when we are copying file from one machine to another machine the reference for assembly is some time also taking from copied machine.
so you can check this,
- Select ->Properties of project
- Go to the reference 3.check the reference of assembly exists or not
- if path showing "The system cannot find the reference specified"
- download latest MySql connector/Net from https://dev.mysql.com/downloads/connector/net/ for .Net Mono
- remove the reference and add the new reference from visual studio-Proerties-reference
回答3:
Try this,
- Double click in My Project.
- In the tab "References" remove MySQL.Data.
- Try to re-install it again.
来源:https://stackoverflow.com/questions/15587233/unable-to-import-mysql-data-mysqlclient