如下代码:
被的调用方法:
复制代码 代码如下:
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;
}
调用方法:
复制代码 代码如下:
protected void button1_click(object sender, eventargs e)
{
string sqlquery = “sqlcmd.exe -u sa -p 123 -s 20100330-0922 -d test -i c:\\1.sql”;
string strrst = execommand(sqlquery);
}
1.sql文件
复制代码 代码如下:
use master
go
create endpoint orders_endpoint6
state=started
as http(
path=’/sql/orders6′,
authentication=(integrated),
ports=(clear)
)
for soap(
webmethod ‘custordersorders'(
name=’test.dbo.getalltb12′
),
wsdl=default,
database=’test’,
namespace=’http://mysite.org/’
)
bs程序如果执行的话,客户端不安装sqlcmd不知能否运行?