我查詢外部數據庫連接時,它拋出一個錯誤:錯誤消息關閉PostgreSQL中
ERROR: 25006: cannot execute UNLISTEN during recovery
我的理解是PostgreSQL的調用此每當它完成,這表明這是造成關閉連接。
對我來說奇怪的是,它似乎代碼可以打開到數據庫的連接,但在嘗試關閉連接時出錯。此外,這似乎只是偶爾發生,所以這可能是由於數據庫本身重新啓動?
它是如何postgreSQL可以打開一個連接,但不能關閉一個?
下面是所執行的代碼,麻煩的線是dbConn.Close()
Dim sConnectionString as String = "Server=10.2.21.46;Port=5432;User Id=myuser;Password=mypsw;Database=demos;"
Dim sErrorMessage As String = ""
Dim bConnectionOpen As Boolean = False
Dim dbConn As Npgsql.NpgsqlConnection = New Npgsql.NpgsqlConnection(sConnectionString)
Try
dbConn.Open()
bConnectionOpen = True
Catch
sErrorMessage = "open connection fail."
End Try
If bConnectionOpen Then
Dim cmdTxt As String = sQueryString
Dim cmdTmp As Npgsql.NpgsqlCommand = New Npgsql.NpgsqlCommand(cmdTxt, dbConn)
Dim bReaderOpen As Boolean = False
Dim rsTmp As Npgsql.NpgsqlDataReader
Try
rsTmp = cmdTmp.ExecuteReader()
bReaderOpen = True
Catch
sErrorMessage = "ExecuteReader fail."
End Try
If bReaderOpen Then rsTmp.Close()
rsTmp = Nothing
dbConn.Close()
End If
你能粘貼連接字符串嗎?它可以幫助.. –
服務器= 10.2.21.46;端口= 5432;用戶ID =用戶;密碼= abc123;數據庫=演示; –
你有沒有在數據庫中定義的任何觸發器?我在尋找什麼是執行偵聽或NOTIFY – mvp