主頁(yè) > 知識(shí)庫(kù) > .Net下執(zhí)行sqlcmd的方法

.Net下執(zhí)行sqlcmd的方法

熱門標(biāo)簽:Linux服務(wù)器 百度競(jìng)價(jià)排名 鐵路電話系統(tǒng) 地方門戶網(wǎng)站 網(wǎng)站排名優(yōu)化 呼叫中心市場(chǎng)需求 服務(wù)外包 AI電銷
如下代碼:
被的調(diào)用方法:
復(fù)制代碼 代碼如下:

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;
}

調(diào)用方法:
復(fù)制代碼 代碼如下:

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文件
復(fù)制代碼 代碼如下:

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程序如果執(zhí)行的話,客戶端不安裝sqlcmd不知能否運(yùn)行?
您可能感興趣的文章:
  • SQLServer2005中的SQLCMD工具使用
  • SQLServer按順序執(zhí)行多個(gè)腳本的方法(sqlcmd實(shí)用工具使用方法)

標(biāo)簽:崇左 銅川 黃山 仙桃 蘭州 湘潭 湖南 衡水

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《.Net下執(zhí)行sqlcmd的方法》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266