c# mysql connect mistake - c#

MySqlConnection con = new MySqlConnection("SERVER=http://185.106.208.... ;DATABASE=netcom_demo;UID=root;PASSWORD=test123;");
ı take "unable connect to any of the specified MySql Host"
what can ı do?

The First thing you should do is to check connectivity to the database you can use a tool like Workbench to connect to the database. Also check you can ping the IP address, If you can't connect using a client like Workbench maybe the problem could be a firewall.

This Will help you.
MySqlConnection con = new MySqlConnection("User ID=root;pwd=test123;Initial Catalog=netcom_demo;Data Source=185.106.208....;");

Related

I've a problem with connecting my online hosted MySQL database with my C# application

I have a database hosted for free on 000webhost.com and I'm trying to connect this database to my C# application. When I created the database on 000webhost it gave me this table that I used while building my connection string
And this is my connection string
Server=99.000webhost.io; Database=db_name_that_in_the_table; port=3306; Uid=username_that_in_the_table; Pwd=the_password_i_used_in_phpmyadmin; SSLMode=Preferred
And this is my C# code
try
{
string myconn = "Server=99.000webhost.io; Database=db_name_that_in_the_table; port=3306; Uid=username_that_in_the_table; Pwd=the_password_i_used_in_phpmyadmin; SSLMode=Preferred";
MySqlConnection conn = new MySqlConnection(myconn);
conn.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
When I try to establish the connection I got this error
Unable to connect to any of the specified MySQL hosts.
PS: I got the hostname or the server name and the port from the variables tab in phpMyAdmin.
What is the problem and how to solve it? Thanks in advance.
The problem is that 000webhost.com doesn't support MySQL remote connections. Thanks to #Uueerdo, he pointed me to google about that.

Can I Used wamp server as a db for my web api C#?

I am creating my first webapi on visual studio. I used wamp server as a database and my problem is, I dont know how to connect wamp on my webapi. Is it posible to use wamp instead of microsoft sql server? plss help me guys
use this c# code
string connstring ="Server=localhost;Database=testDB;Uid=UserName;Pwd=yourPassword;";
MySqlConnection connection = new MySqlConnection(connstring);
connection.Open();
Console.WriteLine("Connected");
connection.close();

connection to MySql database on host

I have a problem regarding connecting to my database that is located on my website host server. I have watched few tutorials, took a look on few articles here on stack overflow and read official mysql documentation, and i steel can't connect to it thru my c# console app. This is my code:
string connstring = string.Format("Server=www.vm-consult.com; Database=vmconsul_sitedatabase; Uid=vmconsul_mijovicpetar; Pwd=mypassword");
MySqlConnection connection = new MySqlConnection();
connection.ConnectionString = connstring;
connection.Open();
I have also went to c panel in remote MySQL tab and set "%" to my remote sql hosts.
All the parameters for con string are correct. In server in connection string I also tried to set IP address, did not change anything.
This is exception I get(on the last line: connection.open()):
Unable to connect to any of the specified MySQL hosts.
Any suggestions appreciated. Thanks.
Check connectivity with
telnet www.vm-consult.com 3306
I needed to contact my host provider to enable external connection to the database. Thanks everybody.

Can't connect to SQL Server Express via IP address - c#

I moved from SQL Server 2014 to SQL Server Express (free version) and since then I can't connect to database using SqlConnection with IP.
I can connect local with connection string but when I am using an ip address I get error number 10061, I checked whole net about that error and verified all the issues mentioned: remote connection is allowed, I added port in firewall, enabled tcp in server...
In official version of SQL Server it works fine, but when I moved to EXPRESS free version I can't successfully connect remotely any more.
This is the connection string I use:
SqlConnection cn = new SqlConnection(#"user id = ***; password=***;server=192.168.1.102,1433; Trusted_Connection=no; database=myDatabase; connection timeout=30");
Getting exception error number 10061.
But when I use the local connection string:
SqlConnection cn = new SqlConnection(#"server=ASUS\SQLEXPRESS ;database=myDatabase;user id = ***; password=***;");
That works fine...
What can the problem be?
You still need to specify the instance name when switching to using the I.P to connect.
SqlConnection cn = new SqlConnection(#"user id = ***;
password=***;
server=192.168.1.102\SQLEXPRESS;
Trusted_Connection=no;
database=myDatabase; connection timeout=30");
I should have set the port and ip in server configuration manager.

How can connect MySql Online Database to C# desktop application

I am creating desktop application in c# but i wont to use Online Database created in mysql.
String mysqlConnectionString = "Server=216.14.120.105;Database=xxx_keys;UID=xxx_root;Password=xxx;Port=3306";
MySqlConnection connection = new MySqlConnection(mysqlConnectionString);
connection.Open();
this is the code i am using but i got an error unable to access host.
where i am wrong and if you have any proper code or details then give me.
If this is a MySQL database in local server user "localhost" for server IP as georgi-it also told. But if this is an external database first try to open a telnet connection on dos-prompt to see if there is some firewall block or something like that:
telnet 216.14.120.105 3306
if you don't get an error message and see a blank page then it means you can reach mysql server

Categories

Resources