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;
}
see error in image
You can check the drivers which are installed on your system by going to the ODBC Data Source Administrator. To open it, press ⊞ Win + R , and type in: odbcad32.exe . Then check the tab Drivers for installed drivers. The Name column indicates the exact name you should use in your connection string or DSN.
Amazon Redshift ODBC Driver (32-bit) Choose the System DSN tab to configure the driver for all users on the computer, or the User DSN tab to configure the driver for your user account only. Choose Add. The Create New Data Source window opens. Choose the Amazon Redshift ODBC driver, and then choose Finish.
Windows: From the Start menu, navigate to ODBC Data Sources, and then choose the Drivers tab. Locate the Amazon Redshift ODBC Driver from the list of installed ODBC drivers. The version number appears in the Version column.
The Amazon Redshift ODBC Driver is a powerful tool that allows you to connect with live Amazon Redshift data, directly from any applications that support ODBC connectivity. Read, write, and update Amazon Redshift data through a standard ODBC Driver interface.
install 32 bit driver
https://s3.amazonaws.com/redshift-downloads/drivers/AmazonRedshiftODBC32-1.3.1.1000.msi
and replace string driver with
string driver = "{Amazon Redshift (x86)}";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With