Exemplo n.º 1
0
 public static Table Create(string name, Database database)
 {
     return new Table()
     {
         Name = name,
         Database = database
     };
 }
Exemplo n.º 2
0
        public static DatabaseBase Create(ConnectionData connectionData, string password)
        {
            var connectionString=connectionData.GetConnectionString(password);
            var database = new Database();
            try
            {
                var connection = new MySqlConnection(connectionString);
                database.Connection=connection;

                // Try to connect with the database
                connection.Open();

                // If it works, take setup the the Database object
                database.ConnectionData=connectionData;
                database.Connected=true;
                database.Name=connection.Database;
                database.Key=connection.ConnectionString;
                database.Version=connection.ServerVersion;
                database.Vendor="Oracle Corporation";
                DatabaseBase.AddDatabase(database);
            }
            catch(Exception e)
            {
                database.Connected=false;
                database.Message=e.Message;
                database.LastError=String.Format(
                    "{0}:{1}{2}{3}{4}Source:{5},{6}",
                    e.Message,
                    Environment.NewLine,
                    e.StackTrace,
                    Environment.NewLine,
                    Environment.NewLine,
                    Environment.NewLine,
                    e.Source
                );
            }
            return database;
        }