1

I have got a problem with connection with MySQL Database. I got MySQLData.dll. My connection string looks like that:

String sCON = "Server=mysql51-105.perso; Database=adamlato;  UID=name; Password=pass";

I have got OVH server. I think server name is a problem. I'm getting the following error:

MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
 ---> System.Net.Sockets.SocketException (0x80004005): Żądana nazwa jest prawidłowa, ale dane żądanego typu nie zostały znalezione
     at System.Net.Dns.GetAddrInfo(String name)
     at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
     at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
     at MySql.Data.Common.MyNetworkStream.GetHostEntry(String hostname)
     at MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder settings, Boolean unix)
     at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
     at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
     at MySql.Data.MySqlClient.NativeDriver.Open()
     at MySql.Data.MySqlClient.NativeDriver.Open()
     at MySql.Data.MySqlClient.Driver.Open()
     at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
     at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
     at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
     at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
     at MySql.Data.MySqlClient.MySqlPool.GetConnection()
     at MySql.Data.MySqlClient.MySqlConnection.Open()
     at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
     at _Default.Page_Load(Object sender, EventArgs e)
 in c:\Users\Adam\Documents\Visual Studio 2013\WebSites\WebSite2\Default.aspx.cs:line 20

4 Answers 4

2
  • Add ProviderName=MySql.Data.MySqlClient to your connection string
  • Add reference MySQL.Data to your project

Additional troubleshooting, Make sure about the following:

  1. database started and accepting queries.
  2. Can you connect to the database locally on the database server?
  3. Do you have a firewall between the web server and the database server or are they on the same machine?

More Help on the following reference: http://www.codeproject.com/Articles/43438/Connect-C-to-MySQL

Sign up to request clarification or add additional context in comments.

5 Comments

2.I can't, database on server what i bought 3.I don't think so FW is a problem.
Before to go to the code part, you should make sure that you can connect to the database and that server is reachable first... please try install toad for mysql, you can download it from here quest.com/toad-for-mysql , try to connect to that server, if you couldn't then you have to solve the network issue before to try it in C#
It is reachable, because before i write page on PHP and every thing works fine, only when i try write at ASP.Net it doesn't work.
Sometimes if you add spaces or wrong connection string then this will give that result, could you please take the connection directly from the following formats in the page: connectionstrings.com/mysql-connector-net-mysqlconnection
@AdamLato To obtain a working connection string, maybe try out using a Data Link Wizard.
0

You are missing provider name. please try this one

String sCON = "Data Source=mysql51-105.perso; Initial Catalog=adamlato;  User Id=name; Password=pass;";

7 Comments

Nope still doesn't work :/ System.ArgumentException: Keyword not supported. Parameter name: providername at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.GetOption(String key) at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.set_Item(String keyword, Object value) at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value) at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor(String connStr) at MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString(String value) at MySql.Data.MySqlClient.MySqlConnection..ctor
could you please use your connection string in web/app.config and then read it from there.
as i see in your connection string might be your server/DB/Username and password are incorrect. May be spelled wrong or you are missing upper or lower case. please check it again.
nope pass,login and database is right, I cheacked it twice. There is a problem with a server.
try to ping your server or try to connect with your database server with Navicat or something like that if server is reachable after that try to fix connection string.
|
0

This error commonly occurs if the connection string isn't specified correctly.

For those coming from a SqlServer background, note that MySql's connection string is very different:

  • providerName="MySql.Data.MySqlClient" in place of providerName="System.Data.SqlClient"

For the connectionString= settings:

  • Server=Host.Name.com (or IP) - (same, but no :Port suffix)
  • Port=nnnn - default to 3306
  • DataBase=MyDatabase. Not Initial Catalog
  • Uid= or User Id= (same)
  • Pwd= or Password= (same)
  • Add Charset=utf8 if you require Unicode Support (e.g. if your Unicode chars are stored as ????)

Comments

0

try modifying your machine.config file to include the present connectionstring alongside the default sqlExpress connectionString. Also make sure your actual connectionstring in your code doesn't contain the port details. Worked for me...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.