English 中文(简体)
电话系统。 进程。 起源于《刑法》中含有Xml的半衰期。
原标题:Call System.Diagnostics.Process.Start from SQL CLR function that contain param with xml

我有一个储存在2008年航天中心服务器项目中的程序。 这项职能称为含有一定微米的ole光应用。

[Microsoft.SqlServer.Server.SqlProcedure()]
public static SqlInt32 ExecuteApp(SqlString utilPath, SqlString arguments, ref SqlString result)  
{
    ProcessStartInfo info  = new ProcessStartInfo("cmd.exe");
    Process p = new Process();

    try
    {
        //ProcessStartInfo to run the DOS command attrib

        info.RedirectStandardOutput = true;
        info.RedirectStandardError = true;
        info.UseShellExecute = false;
        info.CreateNoWindow = true;
        info.Arguments = string.Format(@"/c ""{0}"" {1}", utilPath, arguments);
        SqlContext.Pipe.Send(info.Arguments);

        p.StartInfo = info;
        p.Start();
        String processResults = p.StandardOutput.ReadToEnd();
        SqlContext.Pipe.Send(processResults);
        result = processResults;
        if (String.IsNullOrEmpty((String)result))
            result = p.StandardError.ReadToEnd();

        return 1;
    }
    finally
    {
        p.Close();
    }
}

The problem here with param that contain xml. This is a expression for execute stored procedure:

    declare @Result nvarchar(max)
exec ExecuteApp  C:Console.exe ,  send "<messages><message>my message</message></messages>" , @Result out 
select @Result

执行所储存的程序 我有了一个错误:

并且,目前是意外的。

我要指出,没有x毫升,所有人都是正常工作。

最佳回答

Your XML contains special characters which are interpreted by the command shell (> and <).
You need to quote the parameter and escape quotes inside of it with "".

此外,你应直接执行你的方案(不是通过<条码>cmd/c);这将解决你的一些问题。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签