国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > SQL Server > 正文

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

2020-07-25 13:26:00
字體:
供稿:網(wǎng)友
如下代碼:
被的調(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)行?
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 会泽县| 定边县| 城固县| 元阳县| 洛隆县| 淮安市| 高邮市| 炎陵县| 通化市| 宁津县| 天柱县| 无为县| 三门县| 永吉县| 独山县| 德惠市| 屯门区| 洪泽县| 绍兴市| 井冈山市| 河南省| 永福县| 定兴县| 水城县| 泽库县| 三门峡市| 碌曲县| 孟津县| 茂名市| 蓬安县| 隆子县| 鹤庆县| 安乡县| 林口县| 泽州县| 灵台县| 海宁市| 丹棱县| 峨眉山市| 三亚市| 土默特左旗|