本文整理汇总了C#中Npgsql.NpgsqlConnectionStringBuilder.Add方法的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlConnectionStringBuilder.Add方法的具体用法?C# NpgsqlConnectionStringBuilder.Add怎么用?C# NpgsqlConnectionStringBuilder.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npgsql.NpgsqlConnectionStringBuilder
的用法示例。
在下文中一共展示了NpgsqlConnectionStringBuilder.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConStr
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: MainForm
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: Connect
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();
}
}