I'm trying to open a command prompt through the program and then run bcp. Here is the code.

System.Diagnostics .Process proc = new System.Diagnostics.Process ();
proc.StartInfo.FileName = "bcp";
proc.StartInfo.Arguments = @"select * from dbname" queryout C:\filename.csv -S servername\instance -U sa -P password –N;
proc.Start ();

On the queryout I get an error "; expected"

Any thoughts?

I'm assuming you mean a compile time error and not a runtime error? That would be because you are not terminating or escaping your string properly. Try this:

System.Diagnostics.Process proc = new System.Diagnostics.Process();
      proc.StartInfo.FileName = "bcp";
      proc.StartInfo.Arguments = @"select * from dbname"" queryout C:\filename.csv -S servername\instance -U sa -P password –N";

This code worked :

proc.StartInfo.FileName = "bcp";
proc.StartInfo.Arguments = @"""select * from ims3.dbo.cinfo"" queryout ""C:\filename"" -S server\instance -U sa -P password -N";

I needed to double quote the sub strings.

I'm glad to see you found a solution.

Please mark this thread as solved if your question has been answered

This question has already been answered. Start a new discussion instead.