Example #1
0
        public void Test3Columns()
        {
            const string myFileName = "3columns.bcp";

            BCPWriter writer = new BCPWriter {
                Mode = BCPWriter.BackendMode.Debug
            };

            // FirstName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // LastName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // Birth
            writer.AddColumn(new SQLInt());

            // Try with the wrong number of columns
            // Death
            //writer.AddColumn(new SQLInt());

            List <object> rows = new List <object>();

            rows.Add("Frédéric François");
            rows.Add("Chopin");
            rows.Add(1810);
            rows.Add(1849);

            rows.Add("Franz");
            rows.Add("Liszt");
            rows.Add(1811);
            rows.Add(1886);

            rows.Add("George");
            rows.Add("Sand");
            rows.Add(1804);
            rows.Add(1876);

            try
            {
                BinaryWriter stream = BCPTests.CreateBinaryFile(myFileName);
                writer.WriteRows(stream, rows);
                stream.Close();
            }
            catch (InvalidCastException)
            {
            }
        }
Example #2
0
        public void TestPerformance()
        {
            BCPWriter writer = new BCPWriter {
                Mode = BCPWriter.BackendMode.Debug
            };

            // FirstName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // LastName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // Birth
            writer.AddColumn(new SQLInt());

            // Death
            writer.AddColumn(new SQLInt());

            const int nbRows = 100000;

            List <object> rows = new List <object>();

            for (int i = 0; i < nbRows; i++)
            {
                rows.Add("Frédéric François");
                rows.Add("Chopin");
                rows.Add(1810);
                rows.Add(1849);

                rows.Add("Franz");
                rows.Add("Liszt");
                rows.Add(1811);
                rows.Add(1886);

                rows.Add("George");
                rows.Add("Sand");
                rows.Add(1804);
                rows.Add(1876);
            }

            //string myFileName = "perf.bcp";
            //BinaryWriter stream = BCPTests.CreateBinaryFile(myFileName);
            //writer.WriteRows(stream, rows);
            //stream.Close();

            //BCPTests.CheckFile(myFileName);
        }
Example #3
0
        public void Test3Columns()
        {
            const string myFileName = "3columns.bcp";

            BCPWriter writer = new BCPWriter { Mode = BCPWriter.BackendMode.Debug };

            // FirstName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // LastName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // Birth
            writer.AddColumn(new SQLInt());

            // Try with the wrong number of columns
            // Death
            //writer.AddColumn(new SQLInt());

            List<object> rows = new List<object>();
            rows.Add("Frédéric François");
            rows.Add("Chopin");
            rows.Add(1810);
            rows.Add(1849);

            rows.Add("Franz");
            rows.Add("Liszt");
            rows.Add(1811);
            rows.Add(1886);

            rows.Add("George");
            rows.Add("Sand");
            rows.Add(1804);
            rows.Add(1876);

            try
            {
                BinaryWriter stream = BCPTests.CreateBinaryFile(myFileName);
                writer.WriteRows(stream, rows);
                stream.Close();
            }
            catch (InvalidCastException)
            {
            }
        }
Example #4
0
        public void Test4Columns()
        {
            const string myFileName = "4columns.bcp";

            BCPWriter writer = new BCPWriter {
                Mode = BCPWriter.BackendMode.Debug
            };

            // FirstName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // LastName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // Birth
            writer.AddColumn(new SQLInt());

            // Death
            writer.AddColumn(new SQLInt());

            List <object> rows = new List <object>();

            rows.Add("Frédéric François");
            rows.Add("Chopin");
            rows.Add(1810);
            rows.Add(1849);

            rows.Add("Franz");
            rows.Add("Liszt");
            rows.Add(1811);
            rows.Add(1886);

            rows.Add("George");
            rows.Add("Sand");
            rows.Add(1804);
            rows.Add(1876);

            BinaryWriter stream = BCPTests.CreateBinaryFile(myFileName);

            writer.WriteRows(stream, rows);
            stream.Close();

            BCPTests.CheckFile(myFileName);
        }
Example #5
0
        public void Test4Columns()
        {
            const string myFileName = "4columns.bcp";

            BCPWriter writer = new BCPWriter { Mode = BCPWriter.BackendMode.Debug };

            // FirstName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // LastName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // Birth
            writer.AddColumn(new SQLInt());

            // Death
            writer.AddColumn(new SQLInt());

            List<object> rows = new List<object>();
            rows.Add("Frédéric François");
            rows.Add("Chopin");
            rows.Add(1810);
            rows.Add(1849);

            rows.Add("Franz");
            rows.Add("Liszt");
            rows.Add(1811);
            rows.Add(1886);

            rows.Add("George");
            rows.Add("Sand");
            rows.Add(1804);
            rows.Add(1876);

            BinaryWriter stream = BCPTests.CreateBinaryFile(myFileName);
            writer.WriteRows(stream, rows);
            stream.Close();

            BCPTests.CheckFile(myFileName);
        }
Example #6
0
        public void TestPerformance()
        {
            BCPWriter writer = new BCPWriter { Mode = BCPWriter.BackendMode.Debug };

            // FirstName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // LastName
            writer.AddColumn(new SQLNVarChar(SQLNVarChar.MAX));

            // Birth
            writer.AddColumn(new SQLInt());

            // Death
            writer.AddColumn(new SQLInt());

            const int nbRows = 100000;

            List<object> rows = new List<object>();
            for (int i = 0; i < nbRows; i++)
            {
                rows.Add("Frédéric François");
                rows.Add("Chopin");
                rows.Add(1810);
                rows.Add(1849);

                rows.Add("Franz");
                rows.Add("Liszt");
                rows.Add(1811);
                rows.Add(1886);

                rows.Add("George");
                rows.Add("Sand");
                rows.Add(1804);
                rows.Add(1876);
            }

            //string myFileName = "perf.bcp";
            //BinaryWriter stream = BCPTests.CreateBinaryFile(myFileName);
            //writer.WriteRows(stream, rows);
            //stream.Close();

            //BCPTests.CheckFile(myFileName);
        }