LitDev.DataBase.ConnectMySql C# (CSharp) Method

ConnectMySql() public method

public ConnectMySql ( string server, string user, string password ) : void
server string
user string
password string
return void
        public void ConnectMySql(string server, string user, string password)
        {
            dbType = DBType.MySql;
            dbConnection = "Server=" + server + ";Uid=" + user + ";Pwd=" + password + ";Database=" + database;
            if (LDDataBase.Connection != "") dbConnection = LDDataBase.Connection;
            cnnMySql = new MySqlConnection(dbConnection);
            cnnMySql.Open();
            commandMySql = new MySqlCommand();
            commandMySql.Connection = cnnMySql;
        }

Usage Example

Ejemplo n.º 1
0
 /// <summary>
 /// Connect to a MySQL database.
 /// This must be called before any SQL methods.
 /// The MySQL service must be running and database with credentials already created, if in doubt use SQLite.
 /// </summary>
 /// <param name="server">The MySQL server (e.g. "localhost").</param>
 /// <param name="user">The MySQL user name.</param>
 /// <param name="password">The MySQL user password.</param>
 /// <param name="database">The MySQL database name.</param>
 /// <returns>A label to identify the database.</returns>
 public static Primitive ConnectMySQL(Primitive server, Primitive user, Primitive password, Primitive database)
 {
     try
     {
         ExtractDll();
         DataBase dataBase = GetDataBase(database, false);
         if (null == dataBase)
         {
             dataBase = new DataBase(database, NextID());
             dataBase.ConnectMySql(server, user, password);
         }
         dataBases.Add(dataBase);
         return(dataBase.name);
     }
     catch (Exception ex)
     {
         Utilities.OnError(Utilities.GetCurrentMethod(), ex);
     }
     return("");
 }
All Usage Examples Of LitDev.DataBase::ConnectMySql