Exemplo n.º 1
0
        private void RunCommands(string scriptPath)
        {
            if (!File.Exists(scriptPath))
            {
                return;
            }

            bool isConsoleApp = Console.OpenStandardInput(1) != Stream.Null;

            using (SqlCommandReaderStreamed sr = new SqlCommandReaderStreamed(scriptPath))
            {
                var commandText = sr.ReadCommand();
                int i           = 1;
                if (isConsoleApp)
                {
                    Console.WriteLine("Running script commands " + i);
                }
                while (!string.IsNullOrWhiteSpace(commandText))
                {
                    RunCommand(commandText);
                    if (isConsoleApp)
                    {
                        Console.SetCursorPosition(0, Console.CursorTop - 1);
                    }
                    i++;
                    if (isConsoleApp)
                    {
                        Console.WriteLine("Running script commands " + i);
                    }
                    commandText = sr.ReadCommand();
                }
            }
        }
Exemplo n.º 2
0
        private void RunCommands(string scriptPath)
        {
            if (!System.IO.File.Exists(scriptPath))
            {
                return;
            }

            using (SqlCommandReaderStreamed sr = new SqlCommandReaderStreamed(scriptPath))
            {
                var commandText = sr.ReadCommand();
                while (!string.IsNullOrWhiteSpace(commandText))
                {
                    RunCommand(commandText);
                    commandText = sr.ReadCommand();
                }
            }
        }
Exemplo n.º 3
0
        private void RunCommands(string scriptPath)
        {
            if (!System.IO.File.Exists(scriptPath))
            {
                return;
            }

            using (SqlCommandReaderStreamed sr = new SqlCommandReaderStreamed(scriptPath))
            {
                var commandText = sr.ReadCommand();
                int i           = 1;
                Console.WriteLine("Running script commands " + i);
                while (!string.IsNullOrWhiteSpace(commandText))
                {
                    RunCommand(commandText);
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                    i++;
                    Console.WriteLine("Running script commands " + i);
                    commandText = sr.ReadCommand();
                }
            }
        }