Page 1 of 1

How can I catch wrong host ?????

Posted: Wed 11 Feb 2009 05:38
by akm
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]

Posted: Thu 12 Feb 2009 11:36
by Plash
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).

Posted: Fri 13 Feb 2009 22:54
by snorkel
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)