SQLDependency错误未处理的异常 [英] SQLDependency Error Unhandled Exception

查看:204
本文介绍了SQLDependency错误未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行基本的数据监视程序时出现以下错误.

未处理的异常:System.ArgumentNullException:值不能为null.
参数名称:connectionString
在System.Data.SqlClient.SqlDependency.Start(String connectionString,String队列,布尔useDefaults)
在SqlDependencyTest.Program.Main(String [] args)

主要代码

静态void Main()
{
Console.WriteLine(启动软件");//仅用于调试
SqlDependency.Start(GlobalVars.RS2Events);
Console.WriteLine("Depend Started";);//仅用于调试

//注册更改...
ConnectForChanges();
Console.WriteLine("Registered");//最后删除
//仅用于测试
Console.WriteLine(对事件"表进行一些更改.");
Console.WriteLine(每次在此发生更改");
Console.WriteLine(程序应收到通知.\ n");
Console.WriteLine(按Enter退出此程序.");
Console.ReadLine();
//退出...
SqlDependency.Stop(GlobalVars.RS2Events);
}

app.config文件中的键

< add key ="RS2EDB" value =数据源= FMVIDSRV1 \ AIUNIVERSAL;数据库= AIUEvents_20100318092430;用户ID = SCIWatcher;密码= SC1Access;">

GlobalVars中的变量
公共静态字符串RS2Events = ConfigurationManager.AppSettings.Get("RS2EDB");


需要帮助

解决方案

您是否已逐步调试程序?从错误中可以清楚地看到RS2Events为null,那么您是否做过什么才能证明错误是错误的,或者确认这是问题并尝试解决呢?


I am getting the following error when I try to run a basic data watching program.

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString
at System.Data.SqlClient.SqlDependency.Start(String connectionString, String queue, Boolean useDefaults)
at SqlDependencyTest.Program.Main(String[] args)

Main code

static void Main()
{
Console.WriteLine("Starting Software");//For debug only
SqlDependency.Start(GlobalVars.RS2Events);
Console.WriteLine("Depend Started";);//for debug only

// Registering for changes...
ConnectForChanges();
Console.WriteLine("Registered");//Delete in end
// Only for testing
Console.WriteLine("Make some changes to the Events table.");
Console.WriteLine("Every time a change happens in this ");
Console.WriteLine("program should be notified.\n");
Console.WriteLine("Hit enter to quit this program.");
Console.ReadLine();
// Quitting...
SqlDependency.Stop(GlobalVars.RS2Events);
}

The key in the app.config file

<add key="RS2EDB" value="Data Source=FMVIDSRV1\AIUNIVERSAL;database=AIUEvents_20100318092430;User ID=SCIWatcher;Password=SC1Access;">

The variable in GlobalVars
public static string RS2Events = ConfigurationManager.AppSettings.Get("RS2EDB");


NEED HELP PLEASE

解决方案

Have you stepped through the debugger ? It''s clear from the error that RS2Events is null, so what have you done to either prove the error is wrong, or to confirm that it is the issue and try to solve it ?


这篇关于SQLDependency错误未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆