How can I catch wrong host ?????

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
akm
Posts: 13
Joined: Mon 16 Apr 2007 01:01
Contact:

How can I catch wrong host ?????

Post by akm » Wed 11 Feb 2009 05:38

Hello

How can I catch wrong host name ?????
The code below catch Error, but have no ANI INFO about error....
In IDE I see SockeException Error

Code: Select all

if (!cbDatabase->Items->Count)
{
	PgConnection1->Username = edUsername->Text;
	PgConnection1->Password = edPassword->Text;
	PgConnection1->Server	= edServer->Text;
//	PgConnection1->Port		= udPort->Position;
	PgConnection1->Database = "template1";
	PgConnection1->GetDatabaseNames(cbDatabase->Items);
	try
	{
		PgConnection1->PerformConnect(false);
	}
	catch	(EPgError &E)
	{
    	ShowMessage("Error is " + E.DetailMsg);
	}
}

How can I cath this error ?????[/code]

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 12 Feb 2009 11:36

In the next PgDAC build there will be an error message in the Message property. This message will look like the following:

Socket error on connect. WSAGetLastError return 11001($2AF9)

You can check the error code in the error message. For example, 11001 code means 'Host not found'. You can find these error codes in the Windows API documentation (Windows Sockets Error Codes).

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Fri 13 Feb 2009 22:54

Plash wrote:In the next PgDAC build there will be an error message in the Message property. This message will look like the following:

Socket error on connect. WSAGetLastError return 11001($2AF9)

You can check the error code in the error message. For example, 11001 code means 'Host not found'. You can find these error codes in the Windows API documentation (Windows Sockets Error Codes).
I don't know of any other pgsql components that do not return the actual tcp/ip error message. Is there anyway pgdac can return it? Otherwise if we want to show the user a friendly message we will have funnel every error message though a routine that can lookup the error code, kind of a pain.

It would be much nicer if pgdac returned this instead of the message above:

Socket error on connect:
Host not found (error code 11001)

Post Reply