最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2010年06月11日 01:17:39   作者:  
遇到這樣一個(gè)問題:程序?qū)崿F(xiàn)創(chuàng)建sqlserver 端點(diǎn),添加webmethod,刪除webmethod,如果直接用ado.net 的sqlhelp 實(shí)現(xiàn),總是報(bào)錯(cuò),后來想到了用sqlcmd
如下代碼:
被的調(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)行?

相關(guān)文章

最新評論

丰都县| 宁阳县| 禹州市| 登封市| 唐海县| 兴业县| 汉中市| 东山县| 科技| 施甸县| 临邑县| 大连市| 北流市| 古丈县| 青河县| 吉安县| 泾源县| 江阴市| 永善县| 伽师县| 什邡市| 娄底市| 蕲春县| 疏附县| 峨眉山市| 玛曲县| 基隆市| 景谷| 兴仁县| 溧阳市| 米易县| 方正县| 敦化市| 河北区| 敦煌市| 东阳市| 清苑县| 夹江县| 乡宁县| 海口市| 香港|