我已经使用MySqlWorkbench制作了sql数据库,并试图使连接抛出Xamarin,并在“ .open();”处不断出错。部分。
我尝试以各种在线方式建立连接-这些都没有用。
1
private const string SERVER= "localhost";
private const string DATABASE = "ReDB";
private const string UID = "root";
private const string PASSWORD = "root";
private static MySqlConnection dbConnect;
public void AddUserDB(User newUser)
{
MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
builder.Server = SERVER;
builder.UserID = UID;
builder.Password = PASSWORD;
builder.Database = DATABASE;
string connString = builder.ToString();
dbConnect = new MySqlConnection(connString);
string query= "INSERT INTO UserDB (...);
MySqlCommand cmd = new MySqlCommand(query,dbConnect);
dbConnect.Open();
cmd.ExecuteNonQuery();
dbConnect.Close();
2
MySqlCommand cmd;
public DatabaseT1()
{
dbConnect = new MySqlConnection("Server=localhost;User=root;Database=ReDB;Port=3306;Password=root");
cmd = new MySqlCommand();
}
public void AddUserDB(User newUser)
{
dbConnect.Open();
cmd.Connection = dbConnect;
cmd.CommandText = "INSERT INTO UserDB (...);
cmd.ExecuteNonQuery();
dbConnect.Close();
}
。
`Error`
System.TypeInitializationException: <Timeout execeeded getting exception details>
-如何彻底解决此问题?> 谢谢:)