应用程序启动时未找到UDL文件异常

时间:2014-12-03 07:09:09

标签: c# sql-server-2008

我编写了以下代码来实现公共连接字符串,以便所有表单都使用我的应用程序的登录表单中提供的连接字符串。应用程序在我的机器上工作正常,但是当我在任何其他机器上运行我的应用程序时,我得到错误"无法建立与服务器的连接" 即进入catch块。即使UDL文件在机器上可用。任何人都可以帮我纠正这个问题。 感谢

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();

            }

          }

0 个答案:

没有答案
相关问题