maverick
maverick

Reputation: 11

Exception calling "ExecuteReader" with "0" argument(s): "ERROR [57014]

Need help with my Powershell. I am getting error

Exception calling "ExecuteReader" with "0" argument(s): "ERROR [57014] ERROR: canceling statement due to statement timeout; Error while executing the query" At line:1 char:1

My PowerShell as below:

$datetime = (Get-Date).ToString(); 
$sw = [Diagnostics.Stopwatch]::StartNew() 
$DBConnectionString ="Dsn=PostgreSQL;database=test;server=10.x.x.xx;port=5432;uid=xxx;pwd=xxx" 
$DBConn = New-Object System.Data.Odbc.OdbcConnection; $DBConn.ConnectionString = $DBConnectionString; 
$DBConn.Open(); 
$DBCmd = $DBConn.CreateCommand(); 
$DBCmd.CommandText= get-content "C:\data1.sql" 
$rdr=$DBCmd.ExecuteReader(); 
$instance = "DB\DBTEST" 
$userId = "sa" 
$password = "xxxx" 
$sqlconn = "Data Source=$instance;Integrated Security=SSPI;Initial Catalog=Conversion; User Id=$userId; Password=$password"; 
$sqlbc = new-object system.data.sqlclient.Sqlbulkcopy($sqlconn); 
$sqlbc.BulkCopyTimeout = 0; 
$sqlbc.DestinationTableName="Table"; 
$sqlbc.WriteToServer($rdr); 
$sw.Stop(); 
Write-Host "[$($datetime)] [data1] Elapsed time $($sw.Elapsed.TotalMilliseconds) miliseconds"

Really appreciate your help

Upvotes: 1

Views: 699

Answers (2)

Michael Fayad
Michael Fayad

Reputation: 1336

For me, I was getting this timeout error because my client was sending too much data and the execution would timeout.

Upvotes: 0

Juozas Kaunas
Juozas Kaunas

Reputation: 36

Database timeouts means database network accessibility (e.q. firewalls) or DB down issues most of the time. First of all try to check TCP connectivity to DB:

New-Object System.Net.Sockets.TcpClient('10.x.x.xx', 5432)

If it throws errors you or your admins have to open access to DB port to your workstation first.

Upvotes: 1

Related Questions