使用HDBODBC连接

时间:2019-03-21 08:00:18

标签: powershell odbc sap hana

我有这段代码可以使用HDBODBC(在Windows ODBC数据源中配置)连接到SAP HANA:

function Get-ODBCBData ($connectstring, $sql) {
    $Conn = New-Object System.Data.Odbc.ODBCconnection($connectstring)
    $Conn.Open()
    $readcmd = New-Object System.Data.Odbc.ODBCCommand($sql, $Conn)
    $readcmd.CommandTimeout = '300'

    $da = New-Object System.Data.Odbc.ODBCDataAdapter($readcmd)
    $dt = New-Object System.Data.DataTable
    [void]$da.Fill($dt)
    $Conn.Close()
    return $dt
}

$hdbSqlCmd = "myquery"
$hdbConnectionString = "Driver={HDBODBC};ServerNode=xxxxxx.xxx.xxx:30015;UID=username;PWD=password;"
Get-ODBCBData $hdbConnectionString $hdbSqlCmd

但是我得到这个错误:

PowerShell - Error

0 个答案:

没有答案