So I'm developing an application for my school in C#. I need to know how to connect via a proxy server to the MySQL database. I've been having a look around and found the following code:
NetworkCredential credential=new NetworkCredential("User","Password");
WebProxy proxy=new WebProxy("10.0.0.1",808);
proxy.Credentials=credential;
MySqlConnection conn = new MySqlConnection();
conn.ConnectionString = "Host=192.168.0.10;port=3307;user=root;password=root";
conn.Proxy=proxy;
However, the line conn.Proxy=proxy; doesn't work as conn doesn't contain a definition for Proxy.
So how do I connectt to MySQL through a proxy in C#?
For anyone else having the problem, this is how I got around it:
http://www.hanselman.com/blog/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx
Related
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();
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....;");
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.
When I change my sql server Connection to:
SqlConnection dbConn = new SqlConnection("Data Source=localhost; Initial Catalog = Semester 2 Project SD; Integrated Security=SSPI");
It gives me an error saying that it cant find the server or can't connect to it.
Is my string/ sql connection completely wrong or is there anything i need to change in SQL server, or both?
When I use server = BACON1-PC\\SQLEXPRESS it works completely fine though.
What should be the proper structure of Connection string in C# to access SQL Server 2008 R2 over internet using the public ip of the server ?
I used the below connection string . It works fine within our network using local IP but when i am trying to acces it over internet with public IP, I am getting error.
SqlConnection con = new SqlConnection("Data Source=tcp:192.168.0.16,49582;Initial Catalog=TrulyDB;uid=sa;pwd=sa#pass123;");
There are different ways to Create Connection String which depends on
Authentication type as you know
1.> Windows Authentication
2.> SQL Server Authentication
Follow this link
SqlConnection con = new SqlConnection("Data Source=192.168.0.16,49582;Network Library=DBMSSOCN;Initial Catalog=TrulyDB;uid=sa;pwd=sa#pass123;");