我無法從我的C#Windows連接到MySQL窗體應用程序。我也有 invalid username/passwordCsharp的windows應用程序連接MySQL
已經發布了一個問題,但什麼也沒得到解決。 假設我的網站的名字是www.google.com和的cPanel用戶名是imrancpanel,我的cPanel密碼是imranpd,我創建了一個數據庫imrandb,創建數據庫用戶imrandbuser並檢查所有權限,該用戶本網站。這個代碼有什麼問題?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace CSharpMySql
{
class Program
{
static string getString(string msg)
{
Console.Write(msg);
return Console.ReadLine();
}
static void Main(string[] args)
{
string myConnectionString = @"server=google.com;userid=imrancpanel_imrandbuser;
password=imranpd;database=imrandb";
MySqlConnection con = null;
MySqlDataReader reader = null;
string cretablestr = "CREATE TABLE IF NOT EXISTS AutoCaptchaTable (LoginID char(25), Password char(25), ActivationStatus char(25), NofTransactions int);"
try
{
//MySqlConnection
conn = new MySqlConnection(myConnectionString);
conn.Open();
MessageBox.Show("OK");
conn.Close();
}
catch (MySqlException ex)
{
switch (ex.Number)
{
case 0:
MessageBox.Show("Cannot connect to server. Contact administrator");
break;
case 1042:
MessageBox.Show("Can't get hostname address. Check your internet connection. If does not solve, contact Administrator");
break;
case 1045:
MessageBox.Show("Invalid username/password");
break;
}
}
}
}
}
可能重複的[無效的用戶名/密碼](http://stackoverflow.com/questions/18452865/invalid-username-password) –