1
Answer

Cannot Connect To MYSQL DB From Shared Folder

Ask a question
Randy Smith

Randy Smith

11y
1.4k
1

Hi

I am running a very simple app that tries to connect to a MYSQL DB. When I compile and run on my local C drive, it connects with no problem. But when I compile and run the same exact dode on a shared drive (f drive), I get the Exception below. I've searched the NET everywhere. I've seen others with this problem but have not been able to find a solution. Any ideas why this is happening?

 at MySql.Data.MySqlClient.NativeDriver.Open()
 at MySql.Data.MySqlClient.Driver.Open()
 at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder sett
 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 MYSQLConnect.DB.OpenConnection()
stem.Exception: Call to GetHostEntry failed after 00:00:00 while querying
stname 'lxsrwebdv02.and.ma.zwickerpc.com': SocketErrorCode=NoRecovery, Err
=11003, NativeErrorCode=11003. ---> System.Net.Sockets.SocketException: A
coverable error occurred during a database lookup
 at System.Net.Dns.GetAddrInfo(String name)
 at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeI
 at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
 at MySql.Data.Common.StreamCreator.GetDnsHostEntry(String hostname)
 --- End of inner exception stack trace ---
 at MySql.Data.Common.StreamCreator.GetDnsHostEntry(String hostname)
 at MySql.Data.Common.StreamCreator.GetStream(UInt32 timeout)
 at MySql.Data.MySqlClient.NativeDriver.Open()
42
able to connect to any of the specified MySQL hosts.

Here's my program:


class
Program
{
MySqlConnection connection;

public Program()
{
initDBConnection();
OpenConnection();
}


static void Main(string[] args)
{
new Program();

}
public void initDBConnection()
{
string server;
string database;
string uid;
string password;

server =
"SomeServer.com";
//server = "lxsrnetservpd01.and.ma.zwickerpc.com";
//database = "DebtorDocData";
database =
"SomeDB";
uid =
"SomeUSERID";
password =
"SomePASSWORD";
string connectionString;
connectionString =
"SERVER=" + server + ";" + "DATABASE=" +
database +
";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
connection =
new MySqlConnection(connectionString);

}
public bool OpenConnection()
{
try
{
connection.Open();
Console.WriteLine("CONNECTED");
return true;
}
catch (MySqlException ex)
{
//When handling errors, you can your application's response based
//on the error number.
//The two most common error numbers when connecting are as follows:
//0: Cannot connect to server.
//1045: Invalid user name and/or password.
switch (ex.Number)
{
case 0:
Console.WriteLine("Cannot connect to server. Contact administrator");
break;
case 1042:
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
Console.WriteLine(ex.InnerException);
Console.WriteLine(ex.Number);
break;
case 1045:
Console.WriteLine("Invalid username/password, please try again");
break;
}
Console.WriteLine(ex.Message);
Console.ReadLine();
return false;
}
}
// OpenConnection

}

Answers (1)