예제 #1
0
        public NpgsqlConnectionStringBuilder ConStr()
        {
            string myConnectionString = "";
            NpgsqlConnectionStringBuilder builder = new NpgsqlConnectionStringBuilder(myConnectionString);

            builder.Add("Server", textServer.Text);
            builder.Add("Port", textPort.Text);
            builder.Add("User", textUser.Text);
            builder.Add("Password", textPas.Text);
            builder.Add("Database", textBase.Text);

            return builder;
        }
예제 #2
0
        public MainForm()
        {
            InitializeComponent();
            RecordsProgressBar.Maximum = RecordsMax;
            _count = 0;
            _close = false;
            _threadsCounter = 0;

            DbConnectionStringBuilder connectionStringBuilder = new NpgsqlConnectionStringBuilder();
            connectionStringBuilder.Add("Server", "localhost");
            connectionStringBuilder.Add("Port", "5432");
            connectionStringBuilder.Add("User Id", "postgres");
            connectionStringBuilder.Add("Password", "1");
            connectionStringBuilder.Add("Database", "project");
            _dbConnectionString = connectionStringBuilder.ToString();
        }
예제 #3
0
파일: DB.cs 프로젝트: ratsil/bethe.helpers
		private void Connect()
		{
			lock (_oSyncRoot)
			{
				if (null != _cTransaction)
					return;
				try
				{
					if (null != _cConnection && ConnectionState.Closed != _cConnection.State)
						_cConnection.Close();
				}
				catch { }
				Npgsql.NpgsqlConnectionStringBuilder sConnectionString = new NpgsqlConnectionStringBuilder();
				sConnectionString.Add("Server", _cCredentials.sServer);
				sConnectionString.Add("Port", _cCredentials.nPort);
				sConnectionString.Add("User Id", _cCredentials.sUser);
				sConnectionString.Add("Password", _cCredentials.sPassword);
				sConnectionString.Add("Database", _cCredentials.sDatabase);
				sConnectionString.Add("Timeout", _cCredentials.nTimeout);
                sConnectionString.Add("CommandTimeout", _cCredentials.nTimeout);
                _sLastQuery = sConnectionString.ToString().Replace("\\;", ";") + ";Encoding=Unicode;";
				_cConnection = new NpgsqlConnection(_sLastQuery);
				_sLastQuery = "Connect to server: " + _sLastQuery;
				_cConnection.Open();
				if (null != _cCredentials.sRole && 0 < _cCredentials.sRole.Length)
					(new NpgsqlCommand("SET ROLE " + _cCredentials.sRole, _cConnection)).ExecuteNonQuery();
				if(Preferences.ByteaOutput.server != Preferences.eByteaOutput)
					(new NpgsqlCommand("SET bytea_output TO " + Preferences.eByteaOutput, _cConnection)).ExecuteNonQuery();
			}
		}