Exemple #1
0
        public SqlDataSource(DatasourceConfiguration configurationToTest = null)
        {
            if (configurationToTest != null)
            {
                SetupConnection(configurationToTest);

                if (Connection != null)
                {
                    CloseConnection();
                }
            }
        }
Exemple #2
0
 public static void SaveToLocal(DatasourceConfiguration conf)
 {
     try
     {
         FileStream      fs  = new FileStream(@".\DatasourceConfiguration.conf", FileMode.Create);
         BinaryFormatter bin = new BinaryFormatter();
         bin.Serialize(fs, conf);
         fs.Close();
     }
     catch (Exception ex)
     {
     }
 }
Exemple #3
0
        public override void SetupConnection(DatasourceConfiguration config)
        {
            try
            {
                SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder();
                sb.DataSource     = config.Datasource;
                sb.UserID         = config.UserId;
                sb.Password       = config.Password;
                sb.InitialCatalog = config.InitialCatalog;

                SqlConnection conn = new SqlConnection(sb.ConnectionString);
                conn.Open();

                Connection = conn;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #4
0
        public static DatasourceConfiguration ReadFromLocal()
        {
            FileStream fs = null;

            try
            {
                fs = new FileStream(@".\DatasourceConfiguration.conf", FileMode.Open);
                BinaryFormatter         bin  = new BinaryFormatter();
                DatasourceConfiguration conf = (DatasourceConfiguration)bin.Deserialize(fs);
                fs.Close();

                return(conf);
            }
            catch (Exception ex)
            {
                if (fs != null)
                {
                    fs.Close();
                }

                return(new DatasourceConfiguration());
            }
        }
        public override void SetupConnection(DatasourceConfiguration config)
        {
            try
            {
                FbConnectionStringBuilder sb = new FbConnectionStringBuilder();
                sb.DataSource = config.Datasource;
                if (config.Port > 0)
                {
                    sb.Port = config.Port;
                }
                sb.Database = config.InitialCatalog;
                sb.UserID   = config.UserId;
                sb.Password = config.Password;

                FbConnection conn = new FbConnection(sb.ConnectionString);
                conn.Open();

                Connection = conn;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #6
0
 public abstract void SetupConnection(DatasourceConfiguration config);