C# 应用程序启动时未找到UDL文件异常
我编写了以下代码来实现公共连接字符串,以便所有表单都使用我的应用程序的登录表单中提供的连接字符串。该应用程序在我的计算机上运行良好,但当我在任何其他计算机上运行我的应用程序时,我收到错误“无法建立到服务器的连接”它进入挡块。即使机器上有UDL文件。有人能帮我纠正一下吗。 谢谢C# 应用程序启动时未找到UDL文件异常,c#,sql-server-2008,C#,Sql Server 2008,我编写了以下代码来实现公共连接字符串,以便所有表单都使用我的应用程序的登录表单中提供的连接字符串。该应用程序在我的计算机上运行良好,但当我在任何其他计算机上运行我的应用程序时,我收到错误“无法建立到服务器的连接”它进入挡块。即使机器上有UDL文件。有人能帮我纠正一下吗。 谢谢 也许是防火墙问题?@Sybren谢谢你的回复。我不认为这是防火墙问题 public void FrmLogin_Load(object sender, EventArgs e) {
也许是防火墙问题?@Sybren谢谢你的回复。我不认为这是防火墙问题
public void FrmLogin_Load(object sender, EventArgs e)
{
btncancel.CausesValidation = false;
try
{
string FileName = "Intellect_LeadMt.udl";
if (!File.Exists(FileName))
{
MessageBox.Show(FileName + " File is not available in current folder!");
//return;
this.Close();
}
string[] str = File.ReadAllLines(FileName);
con = new OleDbConnection(str[2]);
con.Open();
add = new AddModify_Lead(this);
foll = new Follow_Lead(this);
rem = new Reminder_Lead(this);
ContctAdd = new AddContact(this);
UtilityMaster = new UtilityMasters(this);
LeadManagerForm = new LeadManager(this);
Register = new FrmRegistration(this);
Mainform = new Form1(this);
Ld = new LoginDetails(this);
Ul = new UserLog(this);
Mc = new Modify_Client(this);
}
catch
{
MessageBox.Show("Connection to Database currently is unavailable!\n Please Check udl and start application once again.\n Sorry For the inconvenience", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
}
}