使用ExecuteReader我能够返回一个DataReader,但out参数返回0.
使用ExecuteNonQuery我能够检索out参数(具有正确的值),但ExecuteNonQuery不返回a DataReader.
这是给出上下文的过程:
CREATE PROCEDURE [dbo].[SelectDays]
@dateStart datetime,
@dateEnd datetime,
@recordCount bigint out
AS
BEGIN
select @recordCount = count(*)
from dbo.[Days]
where [Date]>=@dateStart and [Date]<=@dateEnd;
select [ID],[Name]
from dbo.[Days]
where [Date]>=@dateStart and [Date]<=@dateEnd;
END
Run Code Online (Sandbox Code Playgroud)
有没有一种方法,我可以返回一个DataReader还有out参数,或者我应该为每个两个独立的程序?
Int32 returnValue = 0;
Parameters parameters = new Parameters();
parameters.Add(new SqlParameter("@dateStart", dateStart != null ? (object)dateStart : DBNull.Value));
parameters.Add(new SqlParameter("@dateEnd", dateEnd != null ? (object)dateEnd …Run Code Online (Sandbox Code Playgroud) 我有一个示例控制器:
[RoutePrefix("api/Example")]
public class ExampleController : ApiController
{
[Route("Foo")]
[HttpGet]
public string Foo([FromUri] string startDate)
{
return "This is working";
}
[Route("Bar")]
[HttpPost]
public string Bar([FromBody] DateTime startDate)
{
return "This is not working";
}
}
Run Code Online (Sandbox Code Playgroud)
当我发出GET请求时:http://localhost:53456/api/Example/Foo?startDate=2016-01-01它有效.
当我POST到http://localhost:53456/api/Example/Bar我收到HTTP/1.1 400 Bad Request错误.
这是我的POST数据:
{
"startDate":"2016-01-01T00:00:00.0000000-00:00"
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在尝试在 .NET 4.5 控制台应用程序上运行以下代码:
var app = WebApp.Start<Startup>("http://127.0.0.1:9000/");
Run Code Online (Sandbox Code Playgroud)
这适用于我同事的机器,但不适用于我的。
异常消息为“ Exception has been thrown by the target of an invocation.”,内部异常为“ The network location cannot be reached. For information about network troubleshooting, see Windows Help”。
我试过关闭防火墙,重置主机文件,没有运行反病毒,刷新我的 DNS 并清理/重建我的解决方案。
这是堆栈跟踪:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(StartOptions options)
at …Run Code Online (Sandbox Code Playgroud)