Ejemplo n.º 1
0
        public void AddNewOrderFromCSV(string Path)
        {
            _bulkLoader.TableName       = "orders";
            _bulkLoader.FieldTerminator = ";";
            _bulkLoader.LineTerminator  = "\n";
            _bulkLoader.FileName        = Path;

            try
            {
                if (_conn.State == System.Data.ConnectionState.Open)
                {
                    _conn.Close();
                }

                _conn.Open();

                // Upload data from file
                int count = _bulkLoader.Load();
                Console.WriteLine(count + " lines uploaded.");

                _conn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public void myxxx()
        {
            MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection("constring");
            var bl = new MySql.Data.MySqlClient.MySqlBulkLoader(connection);

            bl.TableName           = "mytable";
            bl.FieldTerminator     = ",";
            bl.LineTerminator      = "\r\n";
            bl.FileName            = "myfileformytable.csv";
            bl.NumberOfLinesToSkip = 1;
            var inserted = bl.Load();

            System.Diagnostics.Debug.Print(inserted + " rows inserted.");
        }