示例#1
0
        /// <summary>
        /// 1. Make set the proper connection. Pass all parameters from UI.
        /// REMEMBER: The User doesn't have to know how to format a proper connection string.
        /// </summary>
        /// <param name="settings"></param>
        public void SetConnection(string server,string database,bool isIntegratedSecurity,string login,string password)
        {
            //create a connection object
               _cn = _df.MakeConnection();

               if (_cn == null)
                    throw new Exception("Cannot connect to your data source.");

               string _settings = _cn.ParseSettings(server, database, isIntegratedSecurity.ToString(), login, password);
               try
               {
                    //set connection settings and connect
                    if (!_cn.Connect(_settings))
                         throw new Exception("Cannot connect to your data source.");
               }
               catch { }
        }