diff --git a/pgadmin/db/pgConn.cpp b/pgadmin/db/pgConn.cpp
index a40782b..8f20b47 100644
--- a/pgadmin/db/pgConn.cpp
+++ b/pgadmin/db/pgConn.cpp
@@ -865,6 +865,12 @@ int pgConn::GetStatus() const
 }
 
 
+void pgConn::Reset()
+{
+	PQreset(conn);
+}
+
+
 wxString pgConn::GetVersionString()
 {
 	return ExecuteScalar(wxT("SELECT version();"));
diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
index 6f0fe40..b26d7ec 100644
--- a/pgadmin/frm/frmQuery.cpp
+++ b/pgadmin/frm/frmQuery.cpp
@@ -2416,15 +2416,27 @@ void frmQuery::OnQueryComplete(wxCommandEvent &ev)
 		}
 		else
 		{
-			pgError err = sqlResult->GetResultError();
-			wxString errMsg = err.formatted_msg;
-			wxLogQuietError(wxT("%s"), conn->GetLastError().Trim().c_str());
-
+            wxString errMsg, errMsg2;
 			long errPos;
-			err.statement_pos.ToLong(&errPos);
+
+            if (sqlResult->RunStatus() != CONNECTION_OK)
+            {
+                if (wxMessageBox(_("Connection is down. Do you want to reset it?"), _("Reset connection?"), wxICON_QUESTION | wxYES_NO) == wxYES)
+                {
+                    conn->Reset();
+                    errMsg2 = _("Connection resetted.");
+                }
+            }
+
+            pgError err = sqlResult->GetResultError();
+            errMsg = err.formatted_msg;
+            wxLogQuietError(wxT("%s"), conn->GetLastError().Trim().c_str());
+            err.statement_pos.ToLong(&errPos);
 
 			showMessage(wxString::Format(wxT("********** %s **********\n"), _("Error")));
 			showMessage(errMsg);
+            if (!errMsg2.IsEmpty())
+                showMessage(errMsg2);
 
 			if (errPos > 0)
 			{
diff --git a/pgadmin/include/db/pgConn.h b/pgadmin/include/db/pgConn.h
index 5236fa7..ab764e9 100644
--- a/pgadmin/include/db/pgConn.h
+++ b/pgadmin/include/db/pgConn.h
@@ -241,6 +241,8 @@ public:
 	pgNotification *GetNotification();
 	int GetTxStatus();
 
+    void Reset();
+
 	bool TableHasColumn(wxString schemaname, wxString tblname, const wxString &colname);
 
 protected:
