Beispiel #1
0
 private object ExecuteScalar(string script, SettingClass settings)
 {
     using (var con = new SqlConnection())
     {
         string connectionString = string.Format("Server={0},{4};Database={1};User Id={2};Password={3};", settings.SQLServer, selectedDatabase, settings.SQLUsername, settings.SQLPassword, settings.SQLPort);
         con.ConnectionString = connectionString;
         using (var cmd = new SqlCommand())
         {
             con.Open();
             cmd.Connection  = con;
             cmd.CommandText = script;
             return(cmd.ExecuteScalar());
         }
     }
 }
Beispiel #2
0
 private void ExecutePatch(string script, SettingClass settings)
 {
     StaticObjects.log.Info("Query");
     StaticObjects.log.Info(script);
     using (var con = new SqlConnection())
     {
         string connectionString = string.Format("Server={0},{4};Database={1};User Id={2};Password={3};", settings.SQLServer, selectedDatabase, settings.SQLUsername, settings.SQLPassword, settings.SQLPort);
         con.ConnectionString = connectionString;
         using (var cmd = new SqlCommand())
         {
             con.Open();
             cmd.Connection  = con;
             cmd.CommandText = script;
             cmd.ExecuteNonQuery();
         }
     }
 }
Beispiel #3
0
 private void SettingsForm_Load(object sender, EventArgs e)
 {
     if (File.Exists(Environment.ExpandEnvironmentVariables("%allusersprofile%") + "/PostgreSQLMigrationUtility/Configuration.config"))
     {
         Settings = JsonConvert.DeserializeObject <SettingClass>(File.ReadAllText(Environment.ExpandEnvironmentVariables("%allusersprofile%") + "/PostgreSQLMigrationUtility/Configuration.config"));
         txtMigrationLocation.Text  = Settings.MigrationLocation;
         txtPostgresPort.Text       = Settings.PostgresPort;
         txtPostgreSQLPassword.Text = Settings.PostgresPassword;
         txtPostgreSQLUsername.Text = Settings.PostgresUsername;
         txtPostgresSQL.Text        = Settings.Postgres;
         txtSQLPassword.Text        = Settings.SQLPassword;
         txtSQLPort.Text            = Settings.SQLPort;
         txtSQLServer.Text          = Settings.SQLServer;
         txtSQLUsername.Text        = Settings.SQLUsername;
     }
     else
     {
         Settings = new SettingClass();
     }
 }
Beispiel #4
0
        private DataSet ExecuteDataset(string script, SettingClass settings)
        {
            DataSet ds = new DataSet();

            using (var con = new SqlConnection())
            {
                string connectionString = string.Format("Server={0},{4};Database={1};User Id={2};Password={3};", settings.SQLServer, selectedDatabase, settings.SQLUsername, settings.SQLPassword, settings.SQLPort);
                con.ConnectionString = connectionString;
                using (var cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandText = script;
                    using (var da = new SqlDataAdapter(cmd))
                    {
                        da.Fill(ds);
                    }
                }
            }
            return(ds);
        }