Click here to Skip to main content
15,913,487 members
Home / Discussions / C#
   

C#

 
Questionhi, I want to create Datatable sorted by... Pin
ngoloi26-Jun-08 15:22
ngoloi26-Jun-08 15:22 
AnswerRe: hi, I want to create Datatable sorted by... Pin
Harvey Saayman26-Jun-08 21:09
Harvey Saayman26-Jun-08 21:09 
GeneralRe: hi, I want to create Datatable sorted by... Pin
ngoloi26-Jun-08 22:01
ngoloi26-Jun-08 22:01 
QuestionValidating an SQL Database shape with C# Pin
Jammer26-Jun-08 12:39
Jammer26-Jun-08 12:39 
QuestionBinary Space Partitioning Tree Problem Pin
gigahertz20526-Jun-08 10:07
gigahertz20526-Jun-08 10:07 
QuestionUsing the enterprise data library and an olap database... Pin
Christopher Stratmann26-Jun-08 9:21
Christopher Stratmann26-Jun-08 9:21 
QuestionCapturing output from the FC.exe into a Windows App Pin
Tony169826-Jun-08 6:41
Tony169826-Jun-08 6:41 
AnswerRe: Capturing output from the FC.exe into a Windows App Pin
Harvey Saayman26-Jun-08 21:19
Harvey Saayman26-Jun-08 21:19 
hey there, here's an app i did something similar with...

its a console app that calls "sqlCmd" to run my data base scrips, the output of each of the sqlCmd programs is dispalyed on the calling program.

Hope this helps

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.IO;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.Wmi;
using Microsoft.SqlServer.Management.Common;

namespace CreateDB
{
    public class Program
    {
        public static string database;
        public static string userName;
        public static string password;

        static void Main(string[] args)
        {
            getVariables();

            FileStream fs = new FileStream(@"C:\scripts.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            killDatabase();

            string line = sr.ReadLine();
            while (line != null)
            {
                ProcessStartInfo StartInfo = new ProcessStartInfo("sqlcmd", "-S " + database + " -d master" + " -U " + userName + " -P " + password + " -i " + line);
                Process myProcess = new Process();

                StartInfo.UseShellExecute = false;
                StartInfo.RedirectStandardOutput = true;

                myProcess.StartInfo = StartInfo;
                myProcess.Start();

                Console.Write("Started Process --> ");
                myProcess.WaitForExit();

                StreamReader outputReader = myProcess.StandardOutput;
                Console.WriteLine("Finnished Process ---> output:" + "\r\n");
                Console.WriteLine(outputReader.ReadToEnd());

                Console.WriteLine();
                Console.WriteLine("|------------------------------------------------------------------------------|");
                Console.WriteLine();

                line = sr.ReadLine();
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("DDDD      OOOO    N    N  EEEEEE  ");
            Console.WriteLine("D   D    O    O   NN   N  E       ");
            Console.WriteLine("D    D  O      O  N N  N  EEE     ");
            Console.WriteLine("D    D  O      O  N  N N  EEE     ");
            Console.WriteLine("D   D    O    O   N   NN  E       ");
            Console.WriteLine("DDDD      OOOO    N    N  EEEEEE  ");
            Console.ResetColor();
            Console.Read();
        }

        private static void getVariables()
        {
            Console.Write("Please Enter DataBase Name: ---> ");
            database = Console.ReadLine();

            Console.Write("User Name ---------------------> ");
            userName = Console.ReadLine();

            Console.Write("Password ----------------------> ");
            password = Console.ReadLine();

            Console.Clear();
        }

        private static void killDatabase()
        {
            try
            {
                Server srv = new Server(database);
                srv.KillDatabase("uniclox_db");
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;

                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
        }
    }
}


Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL

you.suck = (you.passion != Programming)

Questioncreating custom buttons with different shapes and colours Pin
steve_rm26-Jun-08 6:30
steve_rm26-Jun-08 6:30 
AnswerRe: creating custom buttons with different shapes and colours Pin
netJP12L26-Jun-08 7:58
netJP12L26-Jun-08 7:58 
Questionerrors and performance Pin
netJP12L26-Jun-08 5:08
netJP12L26-Jun-08 5:08 
AnswerRe: errors and performance Pin
User 665826-Jun-08 5:38
User 665826-Jun-08 5:38 
GeneralRe: errors and performance Pin
Simon P Stevens26-Jun-08 22:27
Simon P Stevens26-Jun-08 22:27 
QuestionOpenFileDialog Initial Directory FTP Directory - Plz Helpp Pin
laziale26-Jun-08 4:49
laziale26-Jun-08 4:49 
QuestionPropertyGrid + filepath Pin
KBou26-Jun-08 4:38
KBou26-Jun-08 4:38 
AnswerRe: PropertyGrid + filepath Pin
led mike26-Jun-08 4:59
led mike26-Jun-08 4:59 
GeneralRe: PropertyGrid + filepath [modified] Pin
KBou26-Jun-08 20:54
KBou26-Jun-08 20:54 
GeneralRe: PropertyGrid + filepath Pin
KBou26-Jun-08 23:23
KBou26-Jun-08 23:23 
Questionsent Mail ?????? Pin
khongkoko26-Jun-08 4:18
khongkoko26-Jun-08 4:18 
AnswerRe: sent Mail ?????? Pin
leppie26-Jun-08 4:28
leppie26-Jun-08 4:28 
Questionwrite to app.config Pin
arkiboys26-Jun-08 3:05
arkiboys26-Jun-08 3:05 
AnswerRe: write to app.config Pin
Giorgi Dalakishvili26-Jun-08 3:11
mentorGiorgi Dalakishvili26-Jun-08 3:11 
GeneralRe: write to app.config Pin
arkiboys26-Jun-08 3:16
arkiboys26-Jun-08 3:16 
QuestionMS Reporting Service Question - Image [modified] Pin
Programm3r26-Jun-08 2:15
Programm3r26-Jun-08 2:15 
Questionbinding xml data to dataset Pin
karthi8426-Jun-08 1:42
karthi8426-Jun-08 1:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.