Monday, February 20, 2012

isqlw.exe from a console app

Can someone who knows a lot more about this than me please tell why, when the following code executes, I get a pop-up window telling me the usage of isqlw.exe?

<code>

strQueryCommandPath = "C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\";

strArguments = "-S(local)\\SQLEXPRESS ";

strArguments += "-Usa ";

strArguments += "-Padminmlc ";

strArguments += "-i" + strCurrentDir + strFileName + " ";

myProcess.StartInfo.WorkingDirectory = strQueryCommandPath;

myProcess.StartInfo.FileName = "ISQLW.EXE";

myProcess.StartInfo.Arguments = strArguments;

myProcess.StartInfo.UseShellExecute = false;

return myProcess.Start();

</code>

I've also tried it with a space in between the - switch and also with quotes around the switch arguments. I've put the entire path in just the StartInfo.FileName instead of switching the working directory as well. I can't for the life of me get it to actually fire off this command for some reason.

p.s. I've also tried using "/"s instead of "-"s as well.

Generally this is becuase you have one of the switches wrong... I would put some debug code to display the command line command that you are trying to run... then copy and past it to see what it look like.

|||I finally got all the switches to go through right, but now it's telling me access is denied to my My Documents folder (where the .bak file is) to do the restore. It keeps erroring and teminating the RESTORE command. It's not read only or anything (not that I'd think that would necessarily affect it) and I don't know why it would throw an OS access denied error on any part of my computer for me.

No comments:

Post a Comment