The following code:
Called method:
Copy codeThe Code is as follows:
Public static string ExeCommand (string commandText)
{
Process p = new Process ();
P. StartInfo. FileName = "cmd.exe ";
P. StartInfo. UseShellExecute = false;
P. StartInfo. RedirectStandardInput = true;
P. StartInfo. RedirectStandardOutput = true;
P. StartInfo. RedirectStandardError = true;
P. StartInfo. CreateNoWindow = true;
String strOutput = null;
Try
{
P. Start ();
P. StandardInput. WriteLine (commandText );
P. StandardInput. WriteLine ("exit ");
StrOutput = p. StandardOutput. ReadToEnd ();
P. WaitForExit ();
P. Close ();
}
Catch (Exception e)
{
StrOutput = e. Message;
}
Return strOutput;
}
Call method:
Copy codeThe Code is as follows:
Protected void button#click (object sender, EventArgs e)
{
String sqlQuery = "sql0000.exe-U sa-P 123-S 20100330-0922-d test-I c: \ 1. SQL ";
String strRst = ExeCommand (sqlQuery );
}
1. SQL File
Copy codeThe Code is as follows:
Use master
Go
Create endpoint Orders_Endpoint6
State = started
As http (
Path = '/SQL/orders6 ',
AUTHENTICATION = (INTEGRATED ),
Ports = (clear)
)
For soap (
WebMethod 'stordersorders '(
Name = 'test. dbo. getalltb12'
),
Wsdl = default,
Database = 'test ',
Namespace = 'HTTP: // mysite.org /'
)
If the BS program is executed, I wonder if sqlcmd is not installed on the client. Can it be run?