Click here to Skip to main content
15,895,667 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to draw double dash line in gdi+ Pin
Berlus14-Jan-10 2:20
Berlus14-Jan-10 2:20 
GeneralRe: how to draw double dash line in gdi+ Pin
DaveyM6914-Jan-10 7:05
professionalDaveyM6914-Jan-10 7:05 
Questionimport many .sql to one .sql Pin
Jassim Rahma13-Jan-10 7:45
Jassim Rahma13-Jan-10 7:45 
AnswerRe: import many .sql to one .sql Pin
dan!sh 13-Jan-10 8:27
professional dan!sh 13-Jan-10 8:27 
AnswerRe: import many .sql to one .sql Pin
Ennis Ray Lynch, Jr.13-Jan-10 8:50
Ennis Ray Lynch, Jr.13-Jan-10 8:50 
GeneralRe: import many .sql to one .sql Pin
Jassim Rahma13-Jan-10 8:56
Jassim Rahma13-Jan-10 8:56 
GeneralRe: import many .sql to one .sql Pin
Ennis Ray Lynch, Jr.13-Jan-10 9:08
Ennis Ray Lynch, Jr.13-Jan-10 9:08 
AnswerRe: import many .sql to one .sql Pin
pradnya_k13-Jan-10 19:03
pradnya_k13-Jan-10 19:03 
Hello,
You can write a small program to read the files on by one and execute the script.
You can also concatenate the scripts read from files and execute a complete script.
Will that help you?

Pradnya

private void RunAllScripts()
        {
            //Create a list of scripts
            List<string> scripts = new List<string>();
            scripts.Add(@"D:\Scripts\Script1.sql");
            scripts.Add(@"D:\Scripts\Script2.sql");
            scripts.Add(@"D:\Scripts\Script3.sql");

            //Open a connection
            Server server = null;
            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection(sqlConnectionString);

                server = new Server(new ServerConnection(conn));

                foreach (string scriptFile in scripts)
                {
                    RunScript(scriptFile, server);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message);
            }
            finally
            {
                if (conn != null)
                    conn.Close();
            }
        }

        private bool RunScript(string path, Server server)
        {
            string script = String.Empty;

            if (!File.Exists(path))
                return false;

            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    script = sr.ReadToEnd();
                }
            }
            catch (Exception ex)
            {
                string msg = String.Format("The script {0} not found. {1}", path, ex.Message);
                MessageBox.Show(msg);
            }

            try
            {
                //Run the script
                server.ConnectionContext.ExecuteNonQuery(script);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message);
                return false;
            }
            return true;
        }

QuestionSetup Problem &Question Pin
Said Ali Jalali13-Jan-10 7:23
Said Ali Jalali13-Jan-10 7:23 
AnswerRe: Setup Problem &Question Pin
SajjadZare13-Jan-10 9:18
SajjadZare13-Jan-10 9:18 
QuestionProlog Pin
farokhian13-Jan-10 6:15
farokhian13-Jan-10 6:15 
AnswerRe: Prolog Pin
Ennis Ray Lynch, Jr.13-Jan-10 6:51
Ennis Ray Lynch, Jr.13-Jan-10 6:51 
GeneralRe: Prolog Pin
farokhian13-Jan-10 6:59
farokhian13-Jan-10 6:59 
AnswerRe: Prolog Pin
Richard MacCutchan13-Jan-10 7:00
mveRichard MacCutchan13-Jan-10 7:00 
QuestionSetDataSourceLocation to CrystalReport Pin
lordofcsharp13-Jan-10 3:59
lordofcsharp13-Jan-10 3:59 
QuestionStrange problems with DataGridView with Panels in the heading [modified] Pin
arnold_w13-Jan-10 3:36
arnold_w13-Jan-10 3:36 
AnswerRe: Strange problems with DataGridView with Panels in the heading Pin
arnold_w13-Jan-10 4:48
arnold_w13-Jan-10 4:48 
QuestionHow to save a webpage to a jpeg Pin
kozu13-Jan-10 3:35
kozu13-Jan-10 3:35 
AnswerRe: How to save a webpage to a jpeg Pin
Nuri Ismail13-Jan-10 3:49
Nuri Ismail13-Jan-10 3:49 
GeneralRe: How to save a webpage to a jpeg Pin
kozu13-Jan-10 6:45
kozu13-Jan-10 6:45 
GeneralRe: How to save a webpage to a jpeg Pin
Luc Pattyn13-Jan-10 9:25
sitebuilderLuc Pattyn13-Jan-10 9:25 
GeneralRe: How to save a webpage to a jpeg Pin
Nuri Ismail13-Jan-10 20:58
Nuri Ismail13-Jan-10 20:58 
Questionthird party components Pin
djsproject13-Jan-10 3:33
djsproject13-Jan-10 3:33 
AnswerRe: third party components Pin
Richard MacCutchan13-Jan-10 3:38
mveRichard MacCutchan13-Jan-10 3:38 
QuestionRe: third party components Pin
djsproject13-Jan-10 3:42
djsproject13-Jan-10 3: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.