在.net开发中,当执行存储过程时出现错误时,从异常中捕获存储过程的参数/值(或整个语句)的最佳解决方案是什么?
有什么通用的解决方案吗?
环境- c#、.net、linq to sql、存储过程、wcf服务
谢谢
代码示例
public IEnumerable<string> GetCountries()
{
using (var db = new L2SDataContext(_connectionString))
{
var result = db.prime_ui_country_get();
return result.Select(item =
我有ASP .Net核心WebApi应用程序,它使用.Net Framework4.6。我使用NLog进行日志记录。我想登录到Azure表存储。为此,我使用AzureTableStorageNLogTarget和NLogExtensions.Logging Nuget软件包。
AzureTableStorageNLogTarget的最新稳定版本为1.0.9,但当我使用该版本时,将得到以下异常:
Could not load type 'Microsoft.Azure.CloudConfigurationManager' from assembly
所以我使用1.0.8版本。
请帮助解决这个编码错误?我是C#和SQL新手,需要一些快速的帮助。
这是我已经拥有的代码,当我调试它时,当我到
string ConnectionString = ConfigurationManager
.ConnectionStrings["Student1"]
.ConnectionString;
错误信息是
空引用异常未处理。
不管我做什么,我似乎都不能纠正这个错误。有什么想法吗?
static class Program
public sta
我试过这个代码:
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Tooling.Connector;
var connectionString = @"AuthType = Office365;
Url = https://myorg.api.crm8.dynamics.com/XRMServices/2011/Organization.svc;Username=user@azureresulticks.onmicrosoft.com;Password=***";
CrmServ
我有一个旧的应用程序,在尝试测试它很长一段时间后,.I得到以下异常:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
我的代码:
public DBConnection(string ConnectionString)
{
this.providerFactory = DbProviderFactories.GetFactory("IBM.Data.Informix");//Exception here
我正在使用的WEBAPI 2有我的应用程序的后端,我使用自定义异常处理与一些好的博客,现在我正在使用它的工作好,但我需要显示我的自定义消息,我正在传递我的自定义异常需要帮助,下面是我的代码!
public class GlobalException: System.Web.Http.ExceptionHandling.ExceptionHandler
{
public override void Handle(ExceptionHandlerContext context)
{
if (context.Exception is ArgumentNullExce
我可以通过尝试在同一个TransactionScope中打开两个连接(即使是第一个连接在打开下一个连接之前已经关闭)来成功地再现这个结果,如下所示:
var connectionString = "some connection";
using (var t = new TransactionScope())
{
using (var con1 = new OracleConnection(connectionString))
{
con1.Open();
}
using (var co
我试图侦听蔚蓝服务总线队列,但在初始化到队列的连接时得到异常。我曾试图寻找一条出路,但却没有成功。注意,我使用的是.NETCore 2.1。下面是如何初始化连接的方法:
// Initialize the connection to Service Bus Queue
_queueClient = QueueClient.CreateFromConnectionString(_interswitchQueueConnectionString, _interswitchQueueName, ReceiveMode.ReceiveAndDelete);
这是一个例外:
System.TypeIn
我正在尝试使用vb.net中的函数来构建一个准备好的语句,以保存到mysql,但是使用mysql的.net连接器提供的示例,我很难让它工作起来。
我的功能是这样的..。
Public Function TestSQLUpdate(ByVal link_id As String, ByRef updatetext As String, ByRef entrytype As String)
Dim conn As New MySqlConnection
Dim cmd As New MySqlCommand
conn.ConnectionString = main.con
我在看一场撞车事故:
致命异常: android.content.Intent.getIntExtra(java.lang.String,:尝试调用虚拟方法的int java.lang.NullPointerException在com.myapp.APKOfferQueueManagerIntentService.onHandleIntent(SourceFile:71) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatch
我有一个C#函数,它使用ODP.NET构造一个参数化的插入查询,由于某种原因,它总是返回"ORA-01401:插入的值对于列来说太大“异常。
我彻底检查了有问题的字符串变量的长度,发现它远远低于数据库列的最大长度( 1024个字符的Varchar2列中有70个字符)。更奇怪的是,如果我将值作为字符串而不是参数变量插入,插入就可以正常工作。下面是代码(参数化):
connectionString = GetConnectionString();
conn = new OracleConnection(connectionString);
OracleDataAdapter oda = n
每当我尝试运行此查询时,都会收到以下错误:
var query = from u in StageEntity.STAGINGINTERACTIONPOINTS
where u.OBJECTID == OBJECT_ID
select u;
"Schema specified is not valid. Errors: \r\nStagingDB.ssdl(2,2) : error 0152:
No Entity Framework provider found for the ADO.NET provider
with invariant name 'Oracle
我有一个IISCore3.1WebAPI,我最近把它推到了一个可以在.NET上运行的dev上。在部署API时,我注意到应用程序没有启动,甚至没有得到详细的IIS堆栈跟踪,只是一个简单的404错误。因此,我检查了Windows事件查看器,发现了以下内容:
System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String
我在visual studio 2012中使用此代码从sql数据库中的数据填充组合框。每次我尝试调试它时,我都会在空引用异常的for循环中得到异常。我希望有人能帮我弄清楚我在这里错过了什么。
私有子StationList_Click(发送者作为对象,e作为EventArgs)处理StationList.Click
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\hendera2\Desktop\Stati
在新的windows server 2016中,当wcf服务试图使用实体框架连接数据库(SQLServer2017)时,我们会遇到异常。在多台机器上运行的代码是相同的。
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. errordetails~ExceptionMessage - The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
这个例子很好用。
@Query("select t from TimeTable t where MONTH(t.date) = ?1 and YEAR(t.date) = ?2")
List<TimeTable> findAll(Integer month, Integer year);
现在我试着用下面的名字替换?1和?2
@Query("select t from TimeTable t where MONTH(t.date) =month and YEAR(t.date) =:year")
List<TimeTable> find
我正在使用另一个.net标准项目中的.net标准项目。我把它打包成nuget包,并在我的项目中包含了dll。当我的项目调用dll来做一些工作时,它首先会更新一个对象。
var account = new Data.Account();
其中,帐户类如下所示:
internal class Account : Base
{
const string NAME = "test";
internal Account() { }
}
基类如下所示:
public abstract class Base
{
protected string connection
我正在尝试将数据绑定到gridView。基本上,我希望将特定的人员记录绑定到gridview,为此,我通过查询获取数据。我还设置了AutoGenerateColumns=True。我的代码执行得很好,但没有异常,也没有错误。请检查并引导。谢谢。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using Sys
我正在尝试使用一个现有的库,它是一个使用EF6.0连接到数据库的.net库。由于Azure函数没有app.config文件,所以我尝试使用C#代码设置连接字符串。但是,在使用我的DB上下文连接到DB时,我得到了以下异常:
System.ArgumentException:名为“System.Data.SqlClient”不变的ADO.NET提供程序要么没有在计算机或应用程序配置文件中注册,要么无法加载。有关详细信息,请参阅内部异常。
System.ArgumentException:在已注册的.NET数据提供程序列表中找不到指定的不变名称“System.Data.SqlClient”
My