private OdbcConnection _internalConnection;
public OdbcConnection InternalConnection
{
get
{
if (_internalConnection == null)
{
Open();
}
return _internalConnection;
}
}
public void Open()
{
_internalConnection = new OdbcConnection(CreateConnectionString());
try
{
if (_internalConnection.State == System.Data.ConnectionState.Closed)
_internalConnection.Open();
}
catch
{
throw;
}
}
private string CreateConnectionString()
{
int endpointPort = 5439;
string driver = "{Amazon Redshift (x64)}";
string connectionString = "Driver={0};Server={1};Database={2};UID={3};PWD={4};Port={5};SSL=true;Sslmode=Require";
connectionString = string.Format(connectionString,
driver,
Parameters[ConnectionParameterType.DataSource],
Parameters[ConnectionParameterType.DatabaseName],
Parameters[ConnectionParameterType.UserName],
Parameters[ConnectionParameterType.Password],
endpointPort);
return connectionString;
}
答案 0 :(得分:5)
安装32位驱动程序
https://s3.amazonaws.com/redshift-downloads/drivers/AmazonRedshiftODBC32-1.3.1.1000.msi
并用
替换字符串驱动程序string driver =“{Amazon Redshift(x86)}”;