Beispiel #1
0
        public List <Database> PegaBanco(long id)
        {
            List <Database>     tabeladebancos = new List <Database>();
            ConnectionSqlServer cc             = new ConnectionSqlServer();

            cc.abrir();
            string cadena = "select b.Name,b.ConnectionString,b.IdDatabase from UserDatabase a inner join Databases b on a.IdDatabase = b.IdDatabase inner join Users c on a.IdUser = c.IdUser where c.IdUser ="******"errado " + err.Message);
            }
            return(tabeladebancos);
        }
Beispiel #2
0
        public Resultado ultimoId()
        {
            Resultado           rr = new Resultado();
            ConnectionSqlServer cc = new ConnectionSqlServer();

            cc.abrir();
            string cadena = "select max(idDatabase) from Databases ";

            try
            {
                SqlCommand    command = new SqlCommand(cadena, cc.conectarbd);
                SqlDataReader lector  = command.ExecuteReader();
                while (lector.Read())
                {
                    rr.textresult = lector[0].ToString();
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("errado " + err.Message);
            }
            return(rr);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Voiture ka = new Voiture
            {
                Brand      = "Ford",
                Model      = "Ka",
                CreateDate = DateTime.Today.AddDays(-1),
                Distance   = 100454356578,
                Power      = 4,
                Sizecar    = 5.25,
                Isitok     = true
            };

            Voiture mustang = new Voiture
            {
                Brand      = "Ford",
                Model      = "Mustang",
                CreateDate = DateTime.Today.AddDays(5),
                Distance   = 100,
                Power      = 360,
                Sizecar    = 5.25,
                Isitok     = true
            };

            Voiture golf = new Voiture
            {
                Brand      = "Volkswagen",
                Model      = "Golf 7",
                CreateDate = DateTime.Today,
                Distance   = 25324,
                Power      = 120,
                Sizecar    = 4.25,
                Isitok     = true
            };

            Voiture aventador = new Voiture
            {
                Brand      = "Lamborghini",
                Model      = "Aventador",
                CreateDate = DateTime.Today,
                Distance   = 2500,
                Power      = 120,
                Sizecar    = 4.25,
                Isitok     = true
            };


            ////Test of MySQL
            ConnectionMySql connectionMySql = new ConnectionMySql("MySQL ODBC 5.3 ANSI Driver", "localhost",
                                                                  "test", "root", "root");

            MySqlMapping.DropTableNextGen(connectionMySql, new Voiture());
            MySqlMapping.CreateTableNextGen(connectionMySql, new Voiture());
            MySqlMapping.InsertNextGen(connectionMySql, ka);
            MySqlMapping.InsertNextGen(connectionMySql, mustang);
            MySqlMapping.InsertNextGen(connectionMySql, golf);
            MySqlMapping.InsertNextGen(connectionMySql, aventador);
            List <Voiture> GarageMySql =
                MySqlMapping.SelectTableNextGen(connectionMySql, "Brand", "Ford", new Voiture());

            ka.Power = 250;
            MySqlMapping.UpdateElementNextGen(connectionMySql, 1, ka);
            MySqlMapping.DeleteElemetFromTableNextGen(connectionMySql, "Brand", "Lamborghini", new Voiture());


            //Test of PostGre
            ConnectionPostGre connectionPostGre = new ConnectionPostGre("PostgreSQL Unicode", "localhost", "5432",
                                                                        "testorm", "postgres", "root");

            PostGreMapping.DropTableNextGen(connectionPostGre, new Voiture());
            PostGreMapping.CreateTableNextGen(connectionPostGre, new Voiture());
            PostGreMapping.InsertNextGen(connectionPostGre, ka);
            PostGreMapping.InsertNextGen(connectionPostGre, mustang);
            PostGreMapping.InsertNextGen(connectionPostGre, golf);
            PostGreMapping.InsertNextGen(connectionPostGre, aventador);
            List <Voiture> GaragePostGre =
                PostGreMapping.SelectTableNextGen(connectionPostGre, "Brand", "Ford", new Voiture());

            PostGreMapping.DeleteElemetFromTableNextGen(connectionPostGre, "Brand", "Lamborghini", new Voiture());
            mustang.Power = 2501;
            PostGreMapping.UpdateElementNextGen(connectionPostGre, 2, mustang);


            //Test of SQL Server
            ConnectionSqlServer connectionSqlServer =
                new ConnectionSqlServer("(local)", "testorm", "dinesh", "root1234");

            SQLServerMapping.DropTableNextGen(connectionSqlServer, new Voiture());
            SQLServerMapping.CreateTableNextGen(connectionSqlServer, new Voiture());
            SQLServerMapping.InsertNextGen(connectionSqlServer, ka);
            SQLServerMapping.InsertNextGen(connectionSqlServer, mustang);
            SQLServerMapping.InsertNextGen(connectionSqlServer, golf);
            SQLServerMapping.InsertNextGen(connectionSqlServer, aventador);

            List <Voiture> GarageSqlServer =
                SQLServerMapping.SelectTableNextGen(connectionSqlServer, "Brand", "Ford", new Voiture());

            SQLServerMapping.DeleteElemetFromTableNextGen(connectionSqlServer, "Model", "Ka", new Voiture());
            aventador.Power = 783;
            SQLServerMapping.UpdateElementNextGen(connectionSqlServer, 4, aventador);
            // SQLServerMapping.DeleteElemetFromTableNextGen("Brand", "Lamborghini", new Voiture());

            Console.WriteLine("End");
        }
Beispiel #4
0
 public FrmPeople(ConnectionSqlServer connectionSqlServer)
 {
     InitializeComponent();
     DalPeople = new DalPeople(connectionSqlServer);
 }
Beispiel #5
0
        private static TableMapper LoadSQLServer(String TableName)
        {
            var TableMapper = new TableMapper();

            var Query = "SELECT " +
                        "UPPER(A.COLUMN_NAME) COLUMN_NAME, " +
                        "LOWER(A.IS_NULLABLE) IS_NULLABLE, " +
                        "LOWER(A.DATA_TYPE) DATA_TYPE, " +
                        "LOWER(A.CHARACTER_MAXIMUM_LENGTH) MAXIMUM_LENGTH, " +
                        "B.COLUMN_KEY " +
                        "FROM " +
                        "INFORMATION_SCHEMA.COLUMNS A LEFT JOIN " +
                        "(SELECT UPPER(KCU.TABLE_NAME) AS TABLE_NAME, " +
                        "      UPPER(KCU.COLUMN_NAME) AS COLUMN_NAME, " +
                        "      CASE WHEN LOWER(TC.CONSTRAINT_TYPE) = 'PRIMARY KEY' THEN 'pk' " +
                        "           WHEN LOWER(TC.CONSTRAINT_TYPE) = 'FOREIGN KEY' THEN 'fk' " +
                        "           WHEN LOWER(TC.CONSTRAINT_TYPE) = 'UNIQUE' THEN NULL " +
                        "           WHEN LOWER(TC.CONSTRAINT_TYPE) = NULL THEN NULL " +
                        "      END AS COLUMN_KEY " +
                        " FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU " +
                        "      LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC " +
                        "      ON KCU.TABLE_NAME = TC.TABLE_NAME " +
                        "      AND KCU.TABLE_SCHEMA = TC.TABLE_SCHEMA " +
                        "      AND KCU.TABLE_CATALOG = TC.TABLE_CATALOG " +
                        "      AND KCU.CONSTRAINT_CATALOG = TC.CONSTRAINT_CATALOG " +
                        "      AND KCU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME " +
                        "      LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC " +
                        "      ON RC.CONSTRAINT_SCHEMA = TC.CONSTRAINT_SCHEMA " +
                        "      AND RC.CONSTRAINT_CATALOG = TC.CONSTRAINT_CATALOG " +
                        "      AND RC.CONSTRAINT_NAME = TC.CONSTRAINT_NAME " +
                        "      LEFT JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CCU " +
                        "      ON RC.UNIQUE_CONSTRAINT_SCHEMA = CCU.CONSTRAINT_SCHEMA " +
                        "      AND RC.UNIQUE_CONSTRAINT_CATALOG = CCU.CONSTRAINT_CATALOG " +
                        "      AND RC.UNIQUE_CONSTRAINT_NAME = CCU.CONSTRAINT_NAME) B " +
                        "      ON A.TABLE_NAME = B.TABLE_NAME AND A.COLUMN_NAME = B.COLUMN_NAME " +
                        "WHERE " +
                        "A.TABLE_NAME = '" + TableName.ToLower() + "'";

            using (var Conexao = new ConnectionSqlServer(Query))
            {
                if (Conexao.Open())
                {
                    TableMapper.TableName = TableName;
                    var CollectionColumnMapper = new List <ColumnMapper>();

                    while (Conexao.LerRegistro())
                    {
                        var Column = new ColumnMapper();

                        Column.ColumnName = Conexao.Ler("COLUMN_NAME").ToString();
                        Column.IsNullable = Conexao.Ler("IS_NULLABLE").ToString();
                        Column.DataType   = Conexao.Ler("DATA_TYPE").ToString();
                        Column.MaxLenght  = Conexao.Ler("MAXIMUM_LENGTH").ToString();
                        Column.ColumnKey  = Conexao.Ler("COLUMN_KEY").ToString();

                        CollectionColumnMapper.Add(Column);
                    }

                    TableMapper.CollectionColumn = CollectionColumnMapper;
                }
            }
            return(TableMapper);
        }
Beispiel #6
0
 private void FrmPrincipal_FormClosing(object sender, FormClosingEventArgs e)
 {
     ConnectionSqlServer?.Dispose();
     ConnectionSqlServer = null;
 }
Beispiel #7
0
 public FrmPrincipal()
 {
     InitializeComponent();
     ConnectionSqlServer = new ConnectionSqlServer();
 }