经过数小时的尝试,我发现Redshift有自己的ODBC连接器。可以在这里找到:
https://docs.aws.amazon.com/redshift/latest/mgmt/install-odbc-driver-windows.html
.
代码如下:
Dim oConn As Object
Set oConn = CreateObject("ADODB.Connection")
Dim cmd As Object
Set cmd = CreateObject("ADODB.Command")
' Connection Parameters
Dim strUsername As String
Dim strPassword As String
Dim strServerAddress As String
Dim strDatabase As String
' User:
strUsername = "***"
' Password:
strPassword = "***"
' Server Address:
strServerAddress = "***"
' Database
strDatabase = "***"
oConn.Open "Driver={Amazon Redshift (x86)};" & _
"Server=" & strServerAddress & ";" & _
"Port=***;" & _
"Database=***;" & _
"Uid=" & strUsername & ";" & _
"Pwd=" & strPassword & ";"