Click here to Skip to main content
15,911,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello,
i hope somebody can help me how to connect to the database server(not localhost). before this i can connect to localhost, but i can't connect to database server.

This my coding before:
C#
ConStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" + textBox_ip.Text + ";PORT= 3306;DATABASE=" + textBox_database.Text + ";UID=" + textBox_username.Text + ";PWD=" + textBox_password.Text;// + " ;OPTION=3";
            OdbcCon = new System.Data.Odbc.OdbcConnection(ConStr);



i still cannot connect to datbase server with ip address = 10.202.1.93..
please help me..

i get error:-
ERROR [HY000][ODBC 3.51]Access denied for use 'root'@'10.211.93.250'(using password:YES)

did i need to install the driver at the server???before this i install the driver in my laptop but the server at other place.
Posted
Updated 8-May-10 4:41am
v4

First, I'd say use string.format to make the code more readable.

ConStr = string.Format("DRIVER={MySQL ODBC 3.51 Driver};SERVER={0};PORT= 3306;DATABASE={1};UID={2};PWD={3};OPTION=3", textBox_ip.Text, textBox_database.Text, textBox_username.Text, textBox_password.Text); 


Obviously, you need to make sure the the address and port, etc. are correct.

You can also look here for examples
http://www.connectionstrings.com/[^]
 
Share this answer
 
Comments
mat_saleh87 6-May-10 8:54am    
thanks for your anwser..
i hope this time my project will work properly
mat_saleh87 7-May-10 10:47am    
i still cannot connect to ip address=10.202.1.93.
[no name] 7-May-10 10:56am    
Are you sure the address is correct? Is it available? Are the correct ports open? Contact the administrator.
I think you mySql server does not allow access on the root account from LAN (only from localhost).

If so, this has nothing with your code, but with your mySql server application. Check the web how to reconfigure it so it allows network access to it.

-- Modified
Here is a link that solves the problem stated above:
http://www.howtogeek.com/howto/programming/mysql-give-root-user-logon-permission-from-any-host/[^]
 
Share this answer
 
v2
Comments
mat_saleh87 8-May-10 5:56am    
Ok..so what should i do to solve it? check the web how to reconfigure what?
You need to check if the user name 'root' has access to the database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900