I wanted to connect mysql with C# But I was faced with the following error
error text:connection unexpectedly terminated
Please help me
When does this error happen? Are you catching the MySqlException?
private static string BuildConnectionStr(string server, string db, string user, string pwd)
{
return string.Format(connParams, server, db, user, pwd);
}
const string connParams = "Data Source={0};;database={1};username={2};password={3}";
public static MySqlConnection MySqlConnectionExample()
{
string server = "LOCALHOST";// if local machine...
string database = "YOUR CATALOG NAME"; // catalog name...
string user = "YOUR USERNAME";
string pwd = "YOUR PASSWORD";
string connStr = BuildConnectionStr(server, database, user, pwd);
MySqlConnection conn = new MySqlConnection(connStr);
try
{
conn.Open();
}
catch (MySqlException ex)
{
Console.WriteLine("Exception: {0}\r\n Stack Trace: {1}", ex.Message, ex.StackTrace);
}
return conn;
}
I think settings on the site isn't true because I used mysql-front software for get Database value from my site but Connection failed
May be you're a beginner to MySQL. So I strong advise you to use toad for mysql. It's free.
http://www.toadsoft.com/toadmysql/
You'll love it. If you can connect to the database, and run queries, we can show you how to use C# to do it.
Thank you for answer
I'll use this software and tell you the result
I get toad software and setup them
I tried connect to my site but I was faced with the following error
MySQL Database Error: Can't connect to MySQL server on '193.200.241.163' (10061) (Remembered answer : "ok" .)
I get toad software and setup them
I tried connect to my site but I was faced with the following error
MySQL Database Error: Can't connect to MySQL server on '193.200.241.163' (10061) (Remembered answer : "ok" .)
Do you have access to the server? Have you tried google'ing "MySql cannot connect 10061"? Here is the first hit I got from that search: Can't connect to MySql (10061)...
I've Contact My Manager host and He solved problem me. now I can connect my site with toad software but I receive error following When I wanted to connect C# to mysql.
An error occurred while retrieving the information from the database:
SELECT command denied to user 'itvan_jas'@'85.9.75.73' for table 'proc'
I've Contact My Manager host and He solved problem me. now I can connect my site with toad software but I receive error following When I wanted to connect C# to mysql.
An error occurred while retrieving the information from the database:
SELECT command denied to user 'itvan_jas'@'85.9.75.73' for table 'proc'
I found the following suggestion on the MySql website: "just add "Use Procedure Bodies=false" in your connection-string"...
You may wish to refer to this website as you continue, but feel free to continue feedback here as well.;)
Link to MySql: http://www.mysql.com/
Not a problem. Did you finally get your connection working?
Yes, when you gave me the following code
"Use Procedure Bodies=false"
I could solve the problem.
Again, thank you
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.