CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    28

    [RESOLVED] SQLCMD does not continue as long as my calling application process live

    Hi all,

    I have a c# application calling a SQLCMD for a long .sql file of 80 MB. When I start the application, SQLCMD creates the database and insert first few thousands of records but then it freezes until I kill the process of my application which calls the SQLCMD. As soon as I kill the application, SQLCMD keeps inserting the rest of the records

    My code is as below
    Code:
    string fileName = @mevcut_adres + @"\sqlscripts\" + @klasor_adi + @"\script.sql";
                    ProcessStartInfo info = new ProcessStartInfo("sqlcmd", @"-A -S " + @sql_server_list.Text + " -U " + @kullanici_adi.Text + " -P " + @kullanici_sifre.Text + " -i \"" + @fileName + "\"");
                    info.UseShellExecute = false;
                    info.CreateNoWindow = true;
                    info.WindowStyle = ProcessWindowStyle.Hidden;
                    info.RedirectStandardOutput = true;
                    using (Process exeProcess = Process.Start(info))
                    {
                        exeProcess.WaitForExit();
                    }
    Any ideas why this may happen?

    Many thanks.

  2. #2
    Join Date
    Jan 2007
    Posts
    28

    Re: SQLCMD does not continue as long as my calling application process live

    Found the problem. It is the "info.RedirectStandardOutput = true;" line. I changed it to false and the problem is solved. Many thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured